• 5 posts get displayed on my blog’s index page.

    10 most recent posts’ titles (w/ links) get displayed in my sidebar.

    However, I would like to display 10 recent posts from 6th post onwards in the sidebar. This should happen only on the index page and for every other section of the blog, the 10 most recent posts’ list should be shown. Is it possible? I am using widgets.

    I’ve attempted to write in PHP what I want. But I know it isn’t right. Please take a look at https://pastebin.ca/858386.

    Thanks in advance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Sridhar Katakam

    (@srikat)

    Anyone else passing this way might want to check this out.

    Jeremy Clark

    (@jeremyclark13)

    I use this on my blog, that way don’t have to mess with sql code. This code will actually uses the value you define in the options for the amount of posts to show on the homepage.

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $paged = $paged + 1;
    query_posts("paged=$paged");
    ?>
    <ul>
         <?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark,nofollow" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile;?>
    </ul>
    </li>
    moshu

    (@moshu)

    OK, I am not a coder… but found earlier some code snippets in the forum and I put together something like this for a theme:

    <ul>
    <?php if (is_home()) { ?>
    <?php  query_posts('showposts=10&offset=5');?>
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <li><a href="<?php the_permalink() ?>"><?php the_title() ?></a></li>
            <?php endwhile; endif; ?>
    <?php } else { ?>
    <?php  query_posts('showposts=10'); ?>
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <li><a href="<?php the_permalink() ?>"><?php the_title() ?></a></li>
            <?php endwhile; endif; ?>
            <?php } ?>
    </ul>

    It displays a list of recent posts as you asked.
    Note: if you go to the “previous post” from the main… it will display the same 10/offset=5 thing!

    Jeremy Clark

    (@jeremyclark13)

    Note: if you go to the “previous post” from the main… it will display the same 5/offset=5 thing!

    If you want a way around that and show a list of previous posts after the ones show on the page, the code I gave above will do this.

    moshu

    (@moshu)

    Wasn’t the OP asking about displaying recent posts in the sidebar?

    Jeremy Clark

    (@jeremyclark13)

    Yes this is true, but I was just throwing that out there for future reference for anyone else reading this topic about exactly what my code did.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Show from nth recent post onwards on index page in the sidebar’ is closed to new replies.