I have custom post type called services which have taxonomies named service-categories.
Lets say I have added a taxonomy called A which has posts x,y,z . The single CPT pages must have a sidebar which displays other posts from the category.
For Eg: If we are on the post X page the sidebar needs to display Contents of Y,Z . If we are Post Y page, the sidebar needs ti display Contents of X and Z and so on.
How can this be achieved?
You need to make use of wp_reset_query()
- so in your sidebar:
query_posts('your_query_here');
if(have_posts()) : while(have_posts()) : the_post();
// Your code
endwhile; endif;
wp_reset_query();
The function resets the page's query. Check out the wp_reset_query() Codex Page for more info.