I'm trying to create a template which will read a tag from the page, then display all the custom posts which share that tag. So for example, I have a custom post type called 'block', and a taxonomy on the block which is called 'appearson', and a tag of that taxonomy called 'products'.
I also have a products page, which shares the 'appearson' taxonomy, and also has the tag 'products'.
I want the products page template to read its appearson tag, then find the custom posts associated with that tag.
This is what I'm trying:
<?php $terms = get_the_terms( $post->id, 'AppearsOn' );?> <?php $args = array( 'post_type' => 'block' 'tax_query' => array( array( 'taxonomy' => 'appearson', 'field' => 'id', 'terms' => '$terms' ) ) ); ?> <?php $the_query = new WP_Query( $args ); ?> <?php while ( $the_query->have_posts() ) : $the_query->the_post();?>
It's not happy with this. Any pointers as to what I'm doing wrong? Blindingly obvious, I'm sure, but my 4 month old baby girl has stolen my brain.
Actually ignore some of that. I'm now doing this:
<?php $terms = get_the_terms( $post->id, 'appearson' );?> <?php query_posts( array( 'post_type' => 'block', 'appearson' => $terms->name ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
So the bit I'm stuck on is getting 'appearson' => $terms to work. Any idea?
<?php $blocktaxonomy = wp_get_object_terms($post->ID, 'appearson'); $blocktaxonomy = $blocktaxonomy ; query_posts( array( 'post_type' => 'block', 'appearson' => $blocktaxonomy ->name ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>