Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
Created November 19, 2017 00:14
Show Gist options
  • Select an option

  • Save jamiemitchell/bbcd5483fa86d57c2ca6038caa494376 to your computer and use it in GitHub Desktop.

Select an option

Save jamiemitchell/bbcd5483fa86d57c2ca6038caa494376 to your computer and use it in GitHub Desktop.
wp_loop_query
<?php
$term = get_queried_object(); //Получаю текущий обьект запроса
// Узнаю текущий id рубрики
$term_id = $term->term_id;
?>
<?php
$args = array(
'post_type' => 'product',
'product_category' => $term->slug,
'posts_per_page' => 10,
'post_status' => 'publish',
'orderby' => 'id',
'order' => 'ASC'
);
$var_name = new WP_Query($args);
while ( $var_name->have_posts() ) : $var_name->the_post();
get_template_part('loop-product');
endwhile;
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment