add_action('init', 'register_script');
function register_script() {
wp_register_script( 'custom_jquery', plugins_url('/js/custom-jquery.js', __FILE__), array('jquery'), '2.5.1' );
wp_register_style( 'new_style', plugins_url('/css/new-style.css', __FILE__), false, '1.0.0', 'all');
wp_enqueue_script('custom_jquery');
wp_enqueue_style('new_style' );
}
<ul class="products">
<?php
$product_ids_on_sale = wc_get_product_ids_on_sale();
$args = array(
'post_type' => 'product',
'post__in' => array_merge( array( 0 ), $product_ids_on_sale )
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
wc_get_template_part( 'content', 'product' );
endwhile;
} else {
echo __( 'Продуктов не найдено' );
}
wp_reset_postdata();
?>
</ul><!--/.products-->
/**
* Получает ID всех объектов используемых в меню
*
* использование $x = cr_menu_items_ID('primary');
* пример возвращаемых данных
* Array (
* [custom] => Array (
* [0] => 807
* )
* [category] => Array (
* [0] => 2
* [1] => 10
* [2] => 22
* )
* [page] => Array (
* [0] => 74
* )
* [woocommerce] => Array (
* [0] => 54
* [1] => 39
* [2] => 40
* )
* )
*
* @param $menu_id - идентификатор меню
* @return array массив с ID элементов меню где ключом будет выступать тип объекта значением массив с id объектов
*/
function cr_menu_items_ID($menu_id)
{
if (($locations = get_nav_menu_locations()) && isset($locations[$menu_id])) {
$menu = wp_get_nav_menu_object($locations[$menu_id]);
$menu_items = wp_get_nav_menu_items($menu->term_id);
}
foreach ($menu_items as $menu_item) {
// print_r($menu_item);
$numbers[$menu_item->object][] = get_post_meta($menu_item->ID, '_menu_item_object_id', true);
}
return $numbers;
}
add_action( 'template_redirect', 'my_checkout_redirect' );
function my_checkout_redirect() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( '%my_custom_url%' );
exit;
}
}
$array = array('post_type' = > 'product',
'tax_query' = array(
array(
'taxonomy' => 'product_cat',
'field' = > 'term_id/slug/name ',
'terms' = 'id/slug/name'
)
)
);
if( wp_is_mobile() ) {
echo 'бла бла бла' // бла бла бла будет видно только на мобильных девайсах
}
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ) ?>" >
<label class="screen-reader-text" for="s">Поиск: </label>
<input type="text" value="<?php echo get_search_query() ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="найти" />
</form>