I have a taxonomy called projects
and it has 4 types of projects. Assume new, current, past, future
.
In taxonomy-projects.php
page I need to show selected taxonomy term
posts only. Assume I selected future
category. Then I need to show all posts under future
.
Here what I have tried so far. But it is returning all the created taxonomies under proejcts
taxonomy and all posts assigned to those created taxonomies.
$projects = get_terms('projects');
foreach($projects as $project) {
wp_reset_query();
$args = array('post_type' => 'project',
'tax_query' => array(
array(
'taxonomy' => 'projects',
'field' => 'slug',
'terms' => $project->slug,
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts()) {
echo '<h2>'.$project->name.'</h2>';
while($loop->have_posts()) : $loop->the_post();
echo '<a href="'.get_permalink().'">'.get_the_title().'</a><br>';
endwhile;
}
}
taxonomy-projects.php
page I need to show selected taxonomy term posts only. Assume I selectedfuture
category. Then I need to show all posts underfuture
." ?taxonomy-projects.php
source code, so we can modify the code get that functionality. @user2584538