Forums

[resolved] get_posts (exclude sticky posts) (4 posts)

  1. Erfo
    Member
    Posted 6 months ago #

    Hi!

    I've a script:
    get_posts('numberposts=1');
    I would like to exclude the sticky posts. How?

    Thanks.

  2. keesiemeijer
    moderator
    Posted 6 months ago #

    Try:

    get_posts( array( 'post__not_in' => get_option( 'sticky_posts' ), 'posts_per_page' => 1 ) );

    http://codex.wordpress.org/Function_Reference/WP_Query#Sticky_Post_Parameters

  3. Erfo
    Member
    Posted 6 months ago #

    Thanks.

  4. keesiemeijer
    moderator
    Posted 6 months ago #

    You're welcome. Glad you got it resolved.

Reply

You must log in to post.

About this Topic

Tags