Skip to content

Instantly share code, notes, and snippets.

@fatihtoprak
Last active March 27, 2017 19:32
Show Gist options
  • Select an option

  • Save fatihtoprak/1ec06222cc883d04d61176e7773e7214 to your computer and use it in GitHub Desktop.

Select an option

Save fatihtoprak/1ec06222cc883d04d61176e7773e7214 to your computer and use it in GitHub Desktop.
Taxonomy loop.
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$q = new WP_Query([
'post_type' => 'directory', // replace with yours post type.
'posts_per_page' => get_option('posts_per_page'),
get_query_var( 'taxonomy' ) => get_query_var( 'term' ),
'paged' => $paged
]);
$temp_query = $wp_query;
$wp_query = null;
$wp_query = $q;
if ( $q->have_posts() ) :
while ( $q->have_posts() ) : $q->the_post();
get_template_part(ARESCHILDPATH.'/loop','directory' );
endwhile;
endif;
wp_reset_postdata();
echo getAresPagination(); // replace with yours pagination.
$wp_query = NULL;
$wp_query = $temp_query;
?>
@fatihtoprak
Copy link
Author

Usage

Working pagination with custom taxonomy archive page.

taxonomy-{tax-name}.php

Create yours file, into yours theme root folder. And call, yours taxonomy archive page from browser.

http://foo.tld/tax-slug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment