I followed the instructions here http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters in regards to using multiple custom taxonomies but my code doesn't seem to be working and I can't figure out why.
I am tagging the page with specific taxonomies so that they'll display a specific page when they are tagged with those taxonomies. For example, if I tag page A with page 1, page 1 will display as a related page.
It's returning the right terms but the query isn't spitting out anything.
Here's my code:
<?php
global $post;
$services_terms = get_the_terms( $post->ID, 'related-services' );
if ( $services_terms && ! is_wp_error( $terms ) ) :
$services_name = array();
foreach ( $services_terms as $services_term ) {
$services_id[] = $services_term->term_taxonomy_id;
}
$services = join( ", ", $services_id );
$related_service = new WP_Query(array(
'posts_per_page' => '4',
'post_type' => 'page',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'related-services',
'field' => 'id',
'terms' => array($services)
),
array(
'taxonomy' => 'related-projects',
'field' => 'id',
'terms' => '730',
'operator' => 'NOT IN'
)
)
));
while($related_service->have_posts()) : $related_service->the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class('serv-block'); ?>>
<div class="serv-title-wrap">
<div class="serv-title"><a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>"><?php the_title(); ?></a></div>
<?php the_post_thumbnail('pro-serv-thumb'); ?>
</div>
</div>
<?php endwhile; endif;
wp_reset_query(); ?>
Any help would be greatly appreciated. Thank you!