Grow your CSS skills. Land your dream job.

Promoting Posts in WordPress to the Front Page

  • # June 30, 2013 at 10:56 pm

    Hi,

    Hoping to get some guidance/assistance with an ability to promote WordPress posts within my theme (TwentyTwelve), so that they always appear on the front page of my site.

    Unsure what is the best way to approach this but I was thinking of being able to “stamp” a post as “OUTSTANDING”, which then based off this stamp, would push this post to the top of the queue, i.e. front page.

    Would appreciate if people could assist with either a plugin or post some code on how I would be able to achieve this within WordPress, using PHP.

    So basically need to:

    a) Work out how to stamp a post as “OUTSTANDING” ?

    b) How to promote these posts, that are “OUTSTANDING”, so that they always appear on the front page of my blog, say for 24 hours?

    Would appreciate any help on achieving the above.

    Thanks.

    # July 1, 2013 at 1:08 am

    If it were me, an easy way would be to create a category with the name “Featured” (or “Outstanding”) and output all articles within that category.

    # July 1, 2013 at 2:56 am

    Sounds good Chris – will give that a go and come back to you.

    Thanks for that.

    # July 1, 2013 at 3:00 pm

    **
    < ?php
    $sticky = get_option ( ‘sticky_posts’ );
    $args = array( ‘numberposts’ => 3, ‘post__in’ => $sticky );
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>

    “>< ?php the_title(); ?>

    < ?php the_excerpt(); ?>
    < ?php endforeach; ?>
    **

    You can also bring a sticky post forward to the front page with this bit of code. Just put it in the loop.

    # July 1, 2013 at 3:05 pm

    Can’t seem to format code. Sorry about that.

    # July 1, 2013 at 3:12 pm

    $sticky = get_option( ‘sticky_posts’ );
    $args = array( ‘numberposts’ => 3, ‘post__in’ => $sticky );
    $lastposts = get_posts( $args );

    foreach($lastposts as $post):
    setup_postdata($post);
    the_title();
    the_excerpt();
    endforeach;

    @eristic am I missing something?

    # July 1, 2013 at 5:24 pm

    @Chrisburton‘s option works. Give those posts a specific category, and then on the home page run a query that shows posts that have that category assigned to it.

    It won’t really put them to the top of your regular list though, it’s just an additional list. If you also list posts the “regular” way on your home page, then those special posts will appear there again as well (unless you add some code that filters them out again).

    # July 1, 2013 at 6:27 pm

    Looks good @chrisburton … Thanks!

    # July 4, 2013 at 12:00 pm

    Thanks for your help guys – all good.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".