Viewing 15 replies - 1 through 15 (of 18 total)
  • Doodlebee

    (@doodlebee)

    I love this idea…maybe this will help? Working great for me!

    Thread Starter ryanoz

    (@ryanoz)

    Thread Starter ryanoz

    (@ryanoz)

    doodlebee,
    thanks for replying. I couldn’t really follow what was going on in the link you posted.
    I did however almost get everything working just how I wanted, YAY!
    Took some time reading thru the docs and testing, but its working. So I figured I would answer my own question here, and maybe it will help someone else.

    So to ONLY show the last entry, pretty simple; just select it from the wordpress admin/options/reading “show at most…”

    To display a list of ONLY the current days entries…
    (without the latest entry)

    <ul>
    <?php $current_month = date('m'); ?>
    <?php $current_year = date('Y'); ?>
    <?php $current_day = date('j'); ?>
    
    <?php query_posts("year=$current_year&monthnum=$current_month&day=$current_day&order=DESC&showposts=10&offset=1"); ?>
    
    <?php rewind_posts(); ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?><br />
    <span><?php the_time('F jS, Y') ?> - <?php wp_link_pages(); ?> <?php comments_number(__('<strong>0</strong> Comments'), __('<strong>1</strong> Comment'), __('<strong>%</strong> Comments')); ?></span></a></li>
    <?php endwhile; ?>
    </ul>

    To show a list of entries made BEFORE the current day…
    (I haven’t figured this one out yet! its going to display the same list as above). To get this to work, I would have to figure out how many posts are in the list above, then set that number as the offset for this list. So i’m still working on it, I guess.

    <ul>
     <?php
     $myposts = get_posts('numberposts=5&offset=1');
     foreach($myposts as $post) :
     ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?>
    <span><?php the_time('F jS, Y') ?> - <?php wp_link_pages(); ?> <?php comments_number(__('<strong>0</strong> Comments'), __('<strong>1</strong> Comment'), __('<strong>%</strong> Comments')); ?></span></a></li>
     <?php endforeach; ?>
     </ul>

    Doodlebee

    (@doodlebee)

    Well, here, I’ll add to this. Query posts is a bit of overkill. Based on what Kafka posted in that previous link I sent, this is what I did, and it works like a charm:

    <?php if (have_posts()) : ?>
    <?php query_posts("showposts=4"); ?>
    <?php while (have_posts()) : the_post();
    
    $postclass = ($post == $posts[0]) ? 'entry-1' : 'entry'; ?>
    
    <div class="post<?php echo $postclass; ?>" id="post-<?php the_ID(); ?>">
    <h2 class="clear"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    <small><?php the_time('F jS, Y') ?></small></h2>
    
    <div class="entry clear">
    <?php if ($postclass == "entry-1") { the_content('Read More &raquo;');}
    else { the_excerpt_reloaded(30, '', '', TRUE, 'Read More &raquo;', FALSE, 1); } ?>
    </div>
    
    <?php if ($postclass == "entry-1") { ?>
    <p class="postmetadata">Posted @ <?php the_time('g:i a') ?> by <?php the_author() ?> |  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    
    <?php } ?>
    </div> <!-- /post -->
    
    <?php endwhile; ?>
    
    <?php endif; ?>

    As you can see, it sets the very first entry (most recent) with a class of it’s own. That means you can style it however you choose via a stylesheet. I also used “the_excerpt_reloaded” so the smaller older posts show the excerpt of the posts, instead of the post itself.

    Hope that helps you (and/or someone else)!

    Thread Starter ryanoz

    (@ryanoz)

    thanks for all the info.
    I have to say though… I don’t think this achieves anything
    that I am trying to accomplish 🙂
    I’m not concerned with HTML or CSS. Once I am able to get the content it can be styled.
    Just trying to display lists <li> of todays posts
    and another list of 5 or 6 posts before today.

    Also, the screen grab in my original post is an actual HTML page, not an image.

    Doodlebee

    (@doodlebee)

    I don’t think this achieves anything
    that I am trying to accomplish 🙂

    it doesn’t?

    Thread Starter ryanoz

    (@ryanoz)

    unfortunately, no it doesn’t.
    Take another look at my original screen grab.
    This link you posted shows the latest post
    and previous post from different days.

    Once again… I need 2 lists…
    a list of ONLY today’s entries (minus the last entry)
    AND a list of entries made prior to today.

    My previous post explains how to show the last entry,
    and a list of all the other entries made TODAY.

    Doodlebee

    (@doodlebee)

    Ah, I see. You’re making lists instead of excerpts at the bottom.

    >>Also, the screen grab in my original post is an actual HTML page, not an image.<<

    Looks like an image to me.

    Anyway, you can still use the above, it’ll make the one post show and you can style it. For the lists, maybe…

    if the only one you can’t get is *before* the previous day, maybe do something like:

    <?php $today = the_time('F jS, Y');
           if ($today < date('F jS, Y')) { ?>
           <ul>
           <li>
    put in your code to display the list of titles, dates and comments
           </li>
           </ul>
    <?php } elseif ($today = date('F jS, Y')) { ?>
    display list of today's posts
    <?php } ?>

    Something like that?

    Thread Starter ryanoz

    (@ryanoz)

    Looks like an image to me.

    haha, well… I meant its a screen grab of an actual HTML page.

    Yea… I think this is exactly what I need. Looks like it might work perfect.
    Thanks for hanging in there with me 🙂

    EDIT: well, this looks like it might be an either/or type setup. Display either today’s entries or previous entries. Either way though, I can use it to show both of them.

    Doodlebee

    (@doodlebee)

    EDIT: well, this looks like it might be an either/or type setup. Display either today’s entries or previous entries. Either way though, I can use it to show both of them.

    Holy crap, you mean it worked? LOL I’ve shocked myself.

    Well, you *might* be able to take it step further then, and set it using the Loop? Maybe by using your “rewind posts” thing, and removing everything after the “elseif” and placing it into the secondary Loop? I’m not sure what the exact coding would be, but hopefully you get the gist of what I mean. So maybe….

    <?php $today = the_time('F jS, Y');
           if ($today < date('F jS, Y')) { ?>
           <ul>
           <li>
    put in your code to display the list of titles, dates and comments
           </li>
           </ul>
    <?php }

    then end the loop, and begin a second one with:

    <?php $today = the_time('F jS, Y');
           if ($today = date('F jS, Y')) { ?>
    display list of today's posts
    <?php } ?>

    Perhaps that would work? I’m sure there’s a better way to do it, but I do know it’s not a big deal to put in more than one Loop per page…

    Thread Starter ryanoz

    (@ryanoz)

    thanks doodlebee,
    I actually haven’t tried this yet, it just looks like it will work or at least gets me going in the right direction.
    I’ve been styling how these list should look when I get them working 🙂

    I’ll update this posts when I have some results.

    Thread Starter ryanoz

    (@ryanoz)

    UUUUUURURUGHGHGHHGHG!
    I can’t describe how angry and frustrated I am right now.
    I’ve been trying to get this to work non-stop for the past
    8hrs! trying different combinations of code, uploading, refreshing! I’m not a programmer and I hate having to pretend to be! I need to get this working, WTF do I do?
    I don’t even know where to begin or end with this. I’ve copied and pasted, deleted, added, and rearranged so many different combinations of PHP/wordpress code my head is spinning.
    So whatever, I’ll paste the code that I have.
    This is creating a list of the past 10 entries.
    I only want a list of 4 entries prior to today.

    <ul>
    
    <?php
    $myposts = get_posts('numberposts=10&order=DESC&offset=1');
    $entrydate = the_date('F jS, Y','','', FALSE);
    $todaysdate = date('F jS, Y');
    foreach($myposts as $post) :
    if ($entrydate < $todaysdate) : ?>
    
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?>
    <span><?php the_time('F jS, Y') ?> - <?php wp_link_pages(); ?> <?php comments_number(__('<strong>0</strong> Comments'), __('<strong>1</strong> Comment'), __('<strong>%</strong> Comments')); ?></span></a></li>
    
    <?php else: ?>
    <?php endif; ?>
    <?php endforeach; ?>
    </ul>
    Doodlebee

    (@doodlebee)

    This is creating a list of the past 10 entries.
    I only want a list of 4 entries prior to today.

    Well, the last 10 entries is because you have “showposts=10” for $myposts – that’s why it’s showing 10 – you should change that to 4.

    I think your $entrydate might be wrong, as well. the_date should be “the_time”. But I still think it’s possible that it’s looking at the code and seeing what *todays’* date is, not the date of the post itself. I think you need to query the database and get the_time() from the posts themselves.

    So *maybe* something like…

    <?php
    $myposts = get_posts('showposts=4&order=DESC&offset=1');
    $todaysdate = date('F jS, Y');
    foreach($myposts as $post) :
    if ($post_date < $todaysdate) : ?>

    Maybe that would help?

    Thread Starter ryanoz

    (@ryanoz)

    Well, the last 10 entries is because you have “showposts=10”

    I know. Doesn’t matter though… if there aren’t 10 entries prior to today then it should only show however many of the 10 that are.

    EDIT: oh, and using $entrydate = the_time('F jS, Y'); ?>;
    displays the date on the webpage.
    The last code you posted… displays a list of the the last 5 entries including todays.

    I can’t believe its this difficult just to display a list of entries made before the current day. Am I the first one to try and do this? Its got to be documented somewhere in all this WP crap. I must be a total idiot!

    Thread Starter ryanoz

    (@ryanoz)

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘displaying last post, todays posts, and previous posts’ is closed to new replies.