• In desperate need of help, and willing to buy a beer for someone. I’m trying to display the latest STICKY in category baseball on the baseball page. If there is no sticky, then display the latest post within the baseball category. Everything works, except if there is a STICKY in football (or whatever), it shows that instead.

    $args = array(
    ‘posts_per_page’ => 1,
    ‘post__in’ => get_option( ‘sticky_posts’ ),
    ‘ignore_sticky_posts’ => 1,
    ‘category_name’ => ‘baseball’
    );
    $the_query = new WP_Query($args);
    if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

    // CODE GOES HERE

    <?php endwhile; ?>

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

  • The topic ‘Display latest sticky (by category) or/else featured by that category’ is closed to new replies.