The problem is that the code works but when i make a post sticky it doesn't appear at first.

The function of the code: It only shows posts that have a thumbnail or a slideshow image.


$args = array(  'numberposts'  => 5,
                'meta_query'   => array(
                    'relation' => 'OR',
                        'key'     => '_thumbnail_id',
                        'compare' => '!=',
                        'value'   => ''
                        'key'     => 'slideshow_image',
                        'compare' => '!=',
                        'value'   => ''

$my_posts = get_posts( $args );
global $post;
foreach( $my_posts as $post ) : setup_postdata($post);


<?php the_post_thumbnail('thumb-small'); ?>
<a href="<?php the_permalink(); ?>">
    <?php the_title(); ?>


get_posts() is a rather generic wrapper for retrieving set of posts and just that. As such it purposely unmakes some of the arguments typical for loops.

Specifically it ignore stickies:

$r['ignore_sticky_posts'] = true;

So if you want more loop-like behavior you should be using instance of WP_Query object instead.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.