0

I am trying to find a way to display a per term featured post on taxonomy archive pages.

So say you navigate to url.com/my_taxonomy/my_term it should show the featured post of my_term above the results of this page.

Making a post "featured" would be done by a custom field named "featured", which is a true/false field.

Edit: the way to go...

    <?php

    $obj = get_queried_object();
    $post_object = get_field('featured', $obj );

    if( $post_object ): 
// override $post
    $post = $post_object;
    setup_postdata( $post ); 

    ?>
<div class="featured">

</div>



<?php wp_reset_postdata(); ?>
<?php endif; ?>

1 Answer 1

0

The way to go would be to create an archive template for your taxonomy. Then you can catch the term requested with a function like get_queried_object(). So now you can do a custom WP_Query querying for both your term and your meta 'featured'

Hope that makes sense

http://codex.wordpress.org/Class_Reference/WP_Query http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display

1
  • Yep, that absolutely makes sense. I went that route on my own as well. Added the code I used to my first post. Thanks for replying to me, wish I could upvote you.
    – Timmy
    Feb 14, 2015 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.