Displaying different featured post in category template (1 post)

  1. sottise
    Posted 3 years ago #

    Hi everyone,
    Here is my problem. I have 5 different categories, displayed in a category template (category.php), with a color by category. I would like to display 1 featured post, for each category. (using the tag "featured", but if you have a better idea...)
    example :
    "baby" have 1 featured post
    "mom" have 1 featured post

    I use this code (found here)

    global $wp_query;
    $args = array_merge( $wp_query->query, array( 'post__not_in' => $do_not_duplicate ) );
    query_posts( $args );
        $args = array(
                'posts_per_page' => 1,
                'tag' => 'featured',
            $featured = new WP_Query($args);
            if($featured->have_posts()): while($featured->have_posts()): $featured->the_post();
            endwhile; else:

    I have the same featured post displayed in all categories. How to display each featured post in their current category ?
    Thanks in advance !

Topic Closed

This topic has been closed to new replies.

About this Topic