Promoting Posts in WordPress to the Front Page
# June 30, 2013 at 10:56 pm
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 3:00 pm
$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_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 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).
You must be logged in to reply to this topic.