I'm making a website with Wordpress for a friend and their summer house organisation. "My" developer made a brilliant theme but they now want to have a sticky post that is always visible before all other posts on the news (blog) page. The template displays the four first posts with a specific grid layout (and I want the sticky post to follow the same layout, look the same as the other posts excerpts) and below that the page content. I've never really known that sticky posts is available in Wordpress by default but I see that I can make any post sticky without special functions in the theme. But how do I make the sticky post always show up as the first post on the first page?
I tried to check the codex but it seems they have changed the site so now there's almost no code to get there. I used that site a lot to grab code for my themes, so this is rather disappointing. It's possible I don't know how to look for it.. I don't know.
However. I found this:
link to wp sticky posts code
But how do I use it to make it do what I want?
This is the code for the list of recent posts:
$args = array(
'numberposts' => 4,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'post_type' => 'post',
'post_status' => 'draft, publish, future, pending, private',
'suppress_filters' => true
$recent_posts = wp_get_recent_posts( $args, ARRAY_A );
if ( $recent_posts ) :
<div class="recent-posts max-width">
foreach( $recent_posts as $post ) :
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post['ID'] ),
<a href="<?php echo esc_attr( get_permalink( $post['ID'] ) ); ?>" class="post"
style="background-image: url(<?php echo esc_attr( $image ); ?>)">
<div class="title"><?php echo $post['post_title']; ?></div>
<?php endforeach; ?>
<?php endif; ?>
Sorry but I don't know how to make the code show up decently here on the forum .
Can anyone help me put it together? Where to use what? I prefer not having to involve the developer who built the theme because he's busy with other projects, but of course if it's too complicated for me to do it I'd have to.
I thought it would be an easy fix because I've added functions to themes before from the codex. But not this time