Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Roshanb54/3cd9e1fbb05b521ee871db30b6b422de to your computer and use it in GitHub Desktop.
Save Roshanb54/3cd9e1fbb05b521ee871db30b6b422de to your computer and use it in GitHub Desktop.
<?php
get_header();
$al_cat_slug = get_queried_object()->slug;
$al_cat_name = get_queried_object()->name;
?>
<h2><?php echo $al_cat_name; ?></h2>
<?php
$al_tax_post_args = array(
'post_type' => 'Your Post Type', // Your Post type Name that You Registered
'posts_per_page' => 999,
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'YOUR TAXONOMY',
'field' => 'slug',
'terms' => $al_cat_slug
)
)
);
$al_tax_post_qry = new WP_Query($al_tax_post_args);
if($al_tax_post_qry->have_posts()) :
while($al_tax_post_qry->have_posts()) :
$al_tax_post_qry->the_post();
?>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
<?php
endwhile;
endif;
get_footer();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment