Forums

home.php - need help with get_post, duplicate posts (5 posts)

  1. joebrooksie
    Member
    Posted 2 years ago #

    I am trying to get a home.page to show the first post with the update icon. SO I created a get_post at the front of home.php, but now that post is repeated directly below. What do I need to do to skip that post?

    Link

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. krembo99
    Member
    Posted 2 years ago #

    you should build a new query ..
    And then use the OFFSET
    Like so :

    First

    <?php $first_query = new WP_Query('showposts=1'); ?>
    <?php while($first_query->have_posts()) : $first_query->the_post();
    $do_not_duplicate = $post->ID; ?>
    <div class="first">
    <h3>the title</h3>
    <?php the_content("»» " . the_title('', '', false)); ?>
    </div>
    <?php endwhile; ?>

    second

    <ul class="second">
    <?php $first_query = new WP_Query('showposts=9&offset=1'); ?> //** 9 is only an example, you can have any number or unlimit /**
    <?php while($first_query->have_posts()) : $first_query->the_post();
    $do_not_duplicate = $post->ID; ?>

    <li id="post-<?php the_ID(); ?>" class="<?=($i%2)?"odd":"even";$i++;?>">" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?>  »»
    <?php endwhile; ?>

    (This example, with the right CSS, wil lalso HIGHLIGHT the first post.

    You can read more about MULTIPLE LOOPS in the codex

  3. krembo99
    Member
    Posted 2 years ago #

    (sorry , the code got messed up above ..

  4. joebrooksie
    Member
    Posted 2 years ago #

    Problem is when I do that the pagination doesn't work. Each new /page/2/ link goes toward the same page.

  5. krembo99
    Member
    Posted 2 years ago #

    well, like i wrote, you need to CSS that ...

Topic Closed

This topic has been closed to new replies.

About this Topic