List posts that have the current url taxonomy

I created a custom post type “projects” and then I created a taxonomy to categorize my projects “categoriesprojects”.

I have dedicated a page that lists my projects randomly via WP_Query (archive-projets.php) in this way:

<?php
$projectslist = array(
‘post_type’=>’projets’,
‘orderby’ => ‘rand’
);
?>
<?php $loop = new WP_Query($projectslist); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

So, if I launch mywebsite.com/projects, my projects are all listed, but now I would like to list projects related to a category only (taxonomy “categoriesprojects”), this way if I launch mywebsite.com/projects for example, I would like to have only posts in the “events” category.

Read more here:: List posts that have the current url taxonomy

Leave a Reply

Your email address will not be published. Required fields are marked *