• Hi there,

    I do have this code that generates the recent post and the output is good.

      <?php query_posts(‘showposts=5’); ?>
      <?php while (have_posts()) : the_post(); ?>

    • “><?php the_title(); ?>
    • <?php the_excerpt(__(‘(more…)’)); ?>

      <?php endwhile;?>

    Now my problem is that…
    How to exclude the current/latest post from the list…

    and is there a way just to limit the characters of the text rather than using excerpt? Thank you for the time in helping me.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter eronkid

    (@eronkid)

    I think I have posted a wrong code…
    Here’s the new one.

    <ul>
    <?php query_posts('showposts=5'); ?>
    
    <?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
    
    <?php the_excerpt(__('(more…)')); ?>
    <?php endwhile;?>
    </ul>

    Again, Thank you.

    In this line:
    <?php query_posts('showposts=5'); ?>
    add the offset to latest post
    <?php wp_query('showposts=5&offset=1'); ?>

    Thread Starter eronkid

    (@eronkid)

    It works, but it also affects the posts in the homepage.

    Thread Starter eronkid

    (@eronkid)

    I don’t get it right.
    you change the <?php query_posts into <?php wp_query ?

    and add the &offset=1 value?

    is that add or change into?

    will I changed the line?

    I should have asked, what theme are you using and which template file are you modifying/or changing the code of? The code above just showed how to offset 1 post (the most recent post from being included).

    Thread Starter eronkid

    (@eronkid)

    I am not changing any theme, I am just placing that php code and I just need some help in editing it, cause I am not a dev.

    BUT my problem is, that code works and your code also but it also takes effect on the main post list, in which my current post becomes invisible.

    I used the php code I posted here on a widget, using PHP EXEC plugin. Cause I wanted it to run on my sidebar, Im customizing my own theme.

    I hope you understand.

    Thread Starter eronkid

    (@eronkid)

    I have seen the problem… I don’t know if this code doesn’t close its own loop? Cause it continuous on outside it’s loop. Can anyone help me with this, thank you.

    <ul>
    <?php query_posts('showposts=5'); ?>
    
    <?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
    
    <?php the_excerpt(__('(more…)')); ?>
    <?php endwhile;?>
    </ul>

    Now I understand where you’re coming from. You need a code for sidebar that won’t interfere with the other loops or queries in your main content. Ok, so that’s a different matter altogether. Here goes:

    <?php
    $the_query = new WP_Query();
    $the_query->query('showposts=4&offset=1');
    while ($the_query->have_posts()) : $the_query->the_post(); ?>
    <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
    <?php the_excerpt(__('(more…)')); ?>
    <?php endwhile; ?>
    </ul>

    Note: per your first post, I have added the offset to 1 which will exclude listing the most recent post in this list you are generating.

    Thread Starter eronkid

    (@eronkid)

    How about just limiting the characters shown? by NOT using excerpt, is there a way around?

    install this plugin
    http://wordpress.org/extend/plugins/content-and-excerpt-word-limit/
    after which in your excerpt and content tags, you have option of indicating number of characters
    e.g.<?php excerpt('10'); ?>

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Current Post not included in Recent post’ is closed to new replies.