Been stuck on this for days, so I thought I'd reach out.
I've created two custom taxonomies, singleclient and dualclient. These are populated with special content via Advanced Custom Fields.
What I'm looking to do is create a custom page template which joins these two taxonomies and prints out content from the two custom taxonomies.
This works for me for one of the taxonomies:
<?php
$args=array(
'post_type' => 'singleclients',
'posts_per_page' => -1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php the_field('client1_img'); ?>
<h3><?php the_field('client1_name'); ?></h3>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
I've tried following what the Wordpress Codex says to do, but I can't seem to get it working. Here's an example which I thought would work, but displays nothing at all.
<?php
$args=array(
'post_type' => 'post',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'singleclients',
'field' => 'slug',
'terms' => 'singleclients'
),
array(
'taxonomy' => 'dualclients',
'field' => 'slug',
'terms' => 'dualclients'
)
)
);
$posts = get_posts( $args );
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php the_field('client1_img'); ?>
<p>print test content</p>
<h3><?php the_field('client1_name'); ?></h3>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
Really pretty frustrated at this point. Anyone know what I am doing wrong and why it won't print out both taxonomies?