Support » Plugins and Hacks » Latest post in an entirely different div and section – help?

Latest post in an entirely different div and section – help?

  • http://www.pajamaspastnoon.com

    Okay, see that little grey box up on the right? That’s where I want the latest post excerpt to go. That box is in it’s own .php file (squaresidebar.php) and is called in with php include on the index.php page.

    I want everything other post to show up below the header image, with a maximum of 3 posts there.

    I’ve tried every thread I can find on this, and nothing’s working for me.

    The ONLY difference right now, is that the most recent post is ALSO showing up below the header image.

    This is probably a simple fix, but I’m stumped.

Viewing 15 replies - 1 through 15 (of 40 total)
  • Okay gang,

    I checked here: http://wordpress.org/support/topic/67784
    and here: http://wordpress.org/support/topic/20617
    and here: http://wordpress.org/support/topic/35504

    And I’m lost. I’ve tried some of what I’ve seen, but it either stops pulling the recent post or gives me a parse error or something like that.

    Here’s the code I have in the squaresidebar.php file to pull in a post:

    <div align="center">
    <h3 id="latest">Most Recent...</h3>
    <?php $my_query = new WP_Query('showposts=1');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>
    <h2 id="latestheadline"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
    from <?php the_time('F jS, Y'); ?></h2>
    <?php the_excerpt('Read more...'); ?>
    <?php endwhile; ?>

    That’s the only code in that file.

    Here’s what I’m using on index.php:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <br /><br />
    <div id="post-<?php the_ID(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/icon_post.gif" alt="" /> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="View Details: <?php the_title(); ?>"><?php the_title(); ?></a></h2></div>
    <!-- End Of Class Title -->
    <div class="small">
    <?php the_time("l j F Y @ g:i a") ?>
    <!-- End Of Class Small -->
    <div class="article">
    <?php the_content("<br />Continue Reading &raquo; <br />" . the_title('','',false), 0). ""; ?>
    <!-- End Of Class Article -->
    <br />
    <div class="postmetadata alt">
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    &nbsp;|&nbsp;<?php _e("Posted in"); ?> <?php the_category(',') ?>
    &nbsp; &nbsp;<?php edit_post_link(); ?>
    <!-- End Of Class Meta -->
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    That’s just “the loop” from the index page, I guess.

    Anyone can give me the proper code here? Please and thank you!

    Well, I looked around some earlier, but it appears that “the_post();” doesn’t have any parameters you can give it to stop display of the latest post at the top in the loop. Now, keep in mind that there are people here that know far far more than I do as regards tags n such; I just normally don’t use them much since my blog needs seem to be much simpler than most; there may indeed be parameters you can set somewhere to accomplish this, and hopefully if so the guy with the info will be along shortly – whoever heesh may be.

    It looks as if your “grey box” shows what it’s supposed to; so if someone has the info to stop display of the latest post from within the loop, that should fix it, right?

    Yes to that, vkaryl! That’s exactly what I need.

    And I forgot – the box ain’t grey anymore… sorry! It’s the one to the right of the header image, with the (currently) purple border. 😛

    Heh – okay, it was grey earlier when I looked…. I’m still kinda digging through codex, if I find anything I’ll holler.

    Thanks for digging for me – I’m just lost!

    Okay, being the space cadet I am, I was looking in the wrong galaxy earlier….

    http://codex.wordpress.org/Template_Tags/get_posts – Now, if you use the default, but tweak the offset from what’s shown in that first example, what happens? You might have to play with it a while, I’m totally unsure how that’s supposed to work….

    Where’s a great plugin programmer like Kafkaesquí when you need him?

    And of course, as I said earlier (I repeat myself in other words) – may be an easy way to do this and I just don’t know of it….

    One of the other posts I’d seen was Kaf’s solution for this, but it confused the heck out of me. LOL

    Hoping for the ultimate easy way out on this one – just to have someone show me, with the code I posted, what to put where. I’m a php/query moron, seriously. 😉

    Thanks for the help vkaryl – I’m going to dig around that codex link and see if I can play with something to get it to work properly. Hopefully as it happens, someone will come along and just hand me the fish, so to speak. LOL

    I vote for you keeping all of that code in one file and just running the loop twice:

    With that, you can have a second loop that displays the “x” most recent posts except for the most recent one. Glance around that page and see if something makes sense to you. We’ll help from there.

    Oh yeah, been there done that one. Hey, link me that post, wouldja? I didn’t know he’d MADE a post about it, but let me look it over, maybe it’ll make some sort of sense to me.

    tsguitar – I’d keep it all in one file but this is a shredded up theme as it is – and I’m worried about moving too many things. I’ve seen somewhere that someone did it this way, I just need to know how.

    vkaryl – I think this was the one I was referring to with Kaf’s solution. I know I saw another one earlier though, just can’t remember where or how I found it. But this one looks like it’s close.

    [You forgot the link….]

    S’okay, I think I found it…. are you on deadline for this? I’ll have to play with all Kaf’s and moshu’s stuff on a sandbox…. and I’ll be gone all day tomorrow….

    ROFL – long day. sorry about that!
    No deadline – and I soooo appreciate your help!

    Well, good…. what I’ll do is start on it first thing Sunday, and please just update this thread if someone else comes along with the answer, ’cause I’ll check here first.

    You rock, chica. Thank you. And yes, if I do get the answer, I’ll get here immediately. 🙂

    What if you use get_posts?

    Here’s what I’m thinking (to be placed in your index.php):

    Let me know if that works. Do you see what it’s trying to do? That’s the most important thing, that you start spotting what code is attempting to do and how.

Viewing 15 replies - 1 through 15 (of 40 total)
  • The topic ‘Latest post in an entirely different div and section – help?’ is closed to new replies.