WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] I dont find in the loop what i want, please help-me. (3 posts)

  1. izaiasalmeida
    Member
    Posted 6 years ago #

    For first, sorry about my english.
    I extensive read http://codex.wordpress.org/The_Loop article, and i dont find what i need, maybe i'm reading the wrong article, but, there it goes.

    i use the follow code to show the newest post from a specify category
    <?php $posts = get_posts( "category=6&numberposts=1" ); ?>
    <?php if( $posts ) : ?>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    but now, i want to show only the third post(2 posts behind the newest), and i dont know what i have to include in this code. If someone could help-me i'm very very glad.

  2. MichaelH
    Member
    Posted 6 years ago #

    Look at the offset parameter of get_posts:

    Template_Tags/get_posts

  3. izaiasalmeida
    Member
    Posted 6 years ago #

    Hey MichaelH thank u very very much. i'm looking on the wrong place.
    For everyone who has the same doubt, i just added the argument offset=2.
    the code
    <?php $posts = get_posts( "category=6&numberposts=1&offset=2" ); ?>
    <?php if( $posts ) : ?>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags