I am creating <strong>custom post type(cpt)</strong> called
. and the taxonomy for the <strong>cpt</strong> is
in wordpress
What I want to achieve is generate a list of the titles of all circular custom post type in current taxonomy page.
the permalink
I tried with this code with no luck, any ideas?
Here are some variable that can be add to the query
<strong>The Query</strong>
Now display the list cpt post from current cpt category
Code:
circular
Code:
circular_category
What I want to achieve is generate a list of the titles of all circular custom post type in current taxonomy page.
the permalink
Code:
/circular_category/free-circular/
I tried with this code with no luck, any ideas?
Here are some variable that can be add to the query
Code:
$cir_cat = $wp_query->get_queried_object();
$cat_name = $cir_cat->name;
$cat_id = $cir_cat->term_id;
$cat_slug = $cir_cat->slug ;
<strong>The Query</strong>
Code:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'circular',
'posts_per_page' => -1,
'order' => 'DESC',
'orderby' => 'post_title',
'category__in' => $cat_id,
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'circular_category',
)
)
);
$circular_query = new WP_Query( $args );
Now display the list cpt post from current cpt category
Code:
<ul id="circulars">
<?php
if($circular_query->have_posts()) :
while($circular_query->have_posts()) : $circular_query->the_post();
?>
<li>
<a href="<?php the_permalink() ?>" title="Link to <?php the_title_attribute() ?>">
<?php get_the_title(); ?>
</a>
</li>
<?php endwhile; ?>
</ul>
<?php
$total_pages = $circular_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/pages/%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('« prev'),
'next_text' => __('next »'),
));
}
?>
<?php else :?>
<h3><?php _e('No Circular found', ''); ?></h3>
<?php endif; ?>
<?php wp_reset_postdata();?>