• Indent

    (@indent)


    I’m trying to implement sticky posts into this custom loop. I’ve tried a lot of different solutions and came really close one time, but it didn’t work properly. So…

    What I want is to display the posts, one of them a sticky post as the first post.

    This is what I have. Is it even possible? Maybe two loops? But how then?

    <ul class="home-recent-list">
    <?php
    	$recent_posts = wp_get_recent_posts(array(
    		'numberposts' => 3, // Number of recent posts thumbnails to display
    		'post_status' => 'publish' // Show only the published posts
    	));
    	foreach( $recent_posts as $post ) : ?>
    		<li>
    			<h6><?php echo $post['post_title'] ?></h6>
    			<?php echo wpautop($post['post_content']); ?>
    		</li>
    	<?php endforeach; wp_reset_query(); ?>
    </ul>

    Would appreciate any suggestions.
    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • dimitris33

    (@dimitris33)

    Hi, i think you need a custom WP query in the first place.I found this topic that might help you.

    codismo

    (@codismo)

    wp_get_recent_posts() uses get_posts() which forces “ignore_sticky_posts” for the query.

    Do a custom query with WP_Query instead of using wp_get_recent_posts()

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom loop including sticky post’ is closed to new replies.