I have an extra taxonomy named Regions (like Categories).
For example my Categories are:
- Villa
- Housekeeper
And my Regions are:
- Mykonos
- Santorini
- Crete
On single post page I want to show related posts by Region and that match a specific Category.
Example: On a Villa (Category) which is in Mykonos (Region) I would like to show on a row the Housekeepers (Category) that has Mykonos (Region) as a Region.
I guess that the code below will show the related by category posts. How it is possible to show only the posts that match both categories of a post?
<?php
$related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 5, 'post__not_in' => array($post->ID) ) );
if( $related ) foreach( $related as $post ) {
setup_postdata($post); ?>
<ul>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<?php the_content('Read the rest of this entry »'); ?>
</li>
</ul>
<?php }
wp_reset_postdata(); ?>