WordPress.org

Support

Support » How-To and Troubleshooting » Connecting a CPT post to a taxonomy archive page

Connecting a CPT post to a taxonomy archive page

  • I created a custom post type for each of my custom taxonomies so that I can achieve the following effect on taxonomy term archive pages:

    Archive Page for Custom Taxonomy:Countries:Scotland
    Introduction to Scotland, grabbed from Custom Post Type: Countries: Scotland

    • Posts tagged “Scotland”
    • Posts tagged “Scotland”
    • Posts tagged “Scotland”

    How can I achieve this? I’ve tagged all CPT:Countries:{country} with CT:Countries:{country} but I’m having trouble writing a PHP query (or finding a relevant shortcode/plugin) to add the post to the top of the taxonomy-countries archive template.

    (I prefer the CPT approach to the Category Meta plugin.)

Viewing 2 replies - 1 through 2 (of 2 total)
  • What do I have to add to this query_posts() query in taxonomy-countries.php to get it to return the right country?

    query_posts('post_type=country&countries=????'); 
    
    	while (have_posts()) : the_post();
    		the_content( 'Read the full post ยป' );
    	endwhile;

    Do you have this $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); in your archives file?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Connecting a CPT post to a taxonomy archive page’ is closed to new replies.
Skip to toolbar