WordPress.org

Ready to get started?Download WordPress

Forums

Loop Help (6 posts)

  1. masellaus
    Member
    Posted 1 year ago #

    What I am wanting to do and I'm not sure how is to include in my loop 10 excerpts on the page but I want to skip the most current 5. I know that I have to put a wp_query somewhere with a number of posts and an offset but I don't know how to modify the current loop seen below to do that. Any help is appreciated.

    <?php $theme->hook('content_before'); ?>
         <?php
             if (have_posts()) : while (have_posts()) : the_post();
                   get_template_part('post', 'homepage');
                endwhile;
             else :
                get_template_part('post', 'noresults');
             endif;
  2. Marvel Labs
    Member
    Posted 1 year ago #

    Dear masellaus.

    care to explain with an example. please mention the site name as well.

  3. masellaus
    Member
    Posted 1 year ago #

    billmasella.com

    It is my personal blog... I have a scroller at the top that has the most recent 5 articles displayed in rotation. I don't want to include those in the main body of that page so I would like it to start at the 6th most recent post in the body so as to not duplicate content on that main page.

  4. masellaus
    Member
    Posted 1 year ago #

    Since it doesn't have the wpquery in there at all I am guessing I would have to add a line to do the query and then use the result somewhere in the while?

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    I'm sorry but your chosen theme is not released under GPL. Non GPL products are not welcome in the WordPress community. Official WordPress policy states that all plugins and themes that are publicly released are required to adhere to http://wordpress.org/about/gpl/

    I would strongly recommend that you read this article and then download another theme.

  6. alchymyth
    Forum Moderator
    Posted 1 year ago #

    general and untested:

    either modify the loop with a query and the 'offset' parameter;

    i.e. add something like this before the 'if(have_posts())':

    global $query_string; query_posts( $query_string .'&offset=5' );

    this will break any pagination you might have had...

    or preferrable, try to get the post ids from the posts in the slider, then use this with the 'post__not_in' parameter in a query before the loop;

    for the approach, see http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action

    http://codex.wordpress.org/Class_Reference/WP_Query

Topic Closed

This topic has been closed to new replies.

About this Topic