Support » Plugins » How to go about a featured post?

  • I am looking to have a featured post in a theme I’m working on, and I’m looking for the best possible way to do it.

    This is what I want to achieve:

    Users go to the dynamic index-page and see a featured post followed by the loop. When on page 2 and so on, no featured post is displayed, only the loop. The same goes for archives, no featured post here.

    Would it be easiest just using the built in featured post or should I look into getting a plugin? The built-in seems good, but I’ve had broken experiences with it if the post is older than what would show up on the first page.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Could you explain a little more about the “broken experiences”? Are you referring to the featured post showing up twice – once at the top of page 1 and again in its original position in the queue of posts in the subsequent pages?

    Say I decide to show 4 posts on every page and the featured is number 6. It will then show either 3 or 5 posts, breaking a grid type design.

    Having it showing up twice, or just get moved in the queue isn’t that big of a deal, as long as the amounts of posts underneath it is the same. So if I have a featured post and 3 posts on page 1, I need it to be able to show 4 regular styled posts on page 2, 3, 4 etc.

    I’ve looked into it more closely and the built-in will work just fine. However there is one little tweak I’d like to implement, but don’t know how: The first page shows different amount of posts dependent on whether the featured post is article 1 or not. Can I have it show featured + 3 on first page no matter what?

    You should be able to do that with some coding.

    You can use the pre_get_posts hook to control the loop but remember to check that you are modifying it at the right spots. So do some checks, for e.g.:

    function stham_mod_query( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            // blah blah blah
    add_action( 'pre_get_posts', 'stham_mod_query' );

    You can also use the get_posts() function to get the posts you need by setting some parameters:
    WP_Query Pagination Parameters

    You would have to limit the number of featured posts displayed to only 1 and ignore all the others since there’s no limit to how many featured posts you can have:
    Display Sticky Posts

    I’m not a whiz at development but I hope the above helps a little.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to go about a featured post?’ is closed to new replies.