query_posts()
taxonomy-product-category.php
, который выводит кастомные посты из кастомной таксономии с работающей пагинацией:$term = get_queried_object();
$term_slug = $term->slug;
$paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
$_posts = new WP_Query( array(
'post_type' => 'product',
'posts_per_page' => 10,
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'product-category',
'field' => 'slug',
'terms' => $term_slug,
),
),
) );
global $wp_query;
$tmp_query = $wp_query;
$wp_query = null;
$wp_query = $_posts;
if ( $_posts->have_posts() ) :
while ( $_posts->have_posts() ) :
$_posts->the_post();
get_template_part( 'template-parts/content-product', 'preview' );
endwhile;
the_posts_pagination( array(
'type' => 'list',
'prev_text' => '<i class="fas fa-angle-double-left"></i>',
'next_text' => '<i class="fas fa-angle-double-right"></i>',
) );
else :
get_template_part( 'template-parts/content', 'none' );
endif;
$wp_query = null;
$wp_query = $tmp_query;
wp_reset_postdata();
$term = get_queried_object();
$term_slug = $term->slug;
$paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
$_posts = new WP_Query( array(
'post_type' => 'product',
'posts_per_page' => 10,
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'product-category',
'field' => 'slug',
'terms' => $term_slug,
),
),
) );
global $wp_query;
$tmp_query = $wp_query;
$wp_query = null;
$wp_query = $_posts;
if ( $_posts->have_posts() ) :
while ( $_posts->have_posts() ) :
$_posts->the_post();
get_template_part( 'template-parts/content-product', 'preview' );
endwhile;
the_posts_pagination( array(
'type' => 'list',
'prev_text' => '<i class="fas fa-angle-double-left"></i>',
'next_text' => '<i class="fas fa-angle-double-right"></i>',
) );
else :
get_template_part( 'template-parts/content', 'none' );
endif;
$wp_query = null;
$wp_query = $tmp_query;
wp_reset_postdata();
* Display or Retrieve the date the current post was written (once per date)
*
* Will only output the date if the current post's date is different from the
* previous one output.
*
* i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
* function is called several times for each post.
<input type="hidden" name="post_type" value="product">
By default, only files changed by the IDE will be uploaded. If files are changed by some other process such as a VCS branch change, transpilation of Sass or LESS or a File Watcher, they are not automatically uploaded. To change this behavior and autoupload these changes as well, enable the Upload external changes option.