WordPress.org

Ready to get started?Download WordPress

Forums

Connecting a CPT post to a taxonomy archive page (3 posts)

  1. ericperson
    Member
    Posted 3 years ago #

    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.)

  2. ericperson
    Member
    Posted 3 years ago #

    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;
  3. HaneD
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic