Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End multiple loop issue – previous posts page is wrong!?

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #27524
    silvers
    Member

    hi!

    i have been trying to do something similar to css-tricks in showing my newest post in a different way to the other posts on the page. that seems all good, however when you click on "older posts" it has a problem as it still shows the newest post on each page, and doesn’t work in the same way css-tricks does.

    could someone help me on this one please? i would really appreciate it.

    this is the site i have the problem on (i know its crap but i am trying!) http://www.mariosuniverse.com/blog

    here is my code… (thanks in advanced)

    do i need a conditional statement to only do it on the home page like <?php if (is_home()) { } ?> ??? if so can someone show me the way? cheers

    Code:

    have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>

    ” rel=”bookmark” title=”Permanent Link to “>

    ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>

    ” rel=”bookmark” title=”Permanent Link to “>


    Not Found

    Sorry, but you are looking for something that isn’t here.

    #69241
    silvers
    Member

    Hiya,

    Just wanted to bump this again. (I won’t keep doing it and piss everyone off).

    I have searched for ages for a fix on this but have still not found the info i am looking for, can anyone help?

    Thanks.

    #69248
    TheDoc
    Member

    It is a fine question, and I feel like I know the answer, but it isn’t coming to me at the moment.

    I’ll ponder it some more, but hopefully Chris catches this one first!

    #69251
    silvers
    Member

    thanks! any help would be gratefully recieved!!

    #69350
    silvers
    Member

    ok so i have been on a wordpress forum and got this info…

    <?php
    $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    if ($paged < 2) {
    // DO STUFF
    }
    ?>

    The guy basically said that this would say that this would check if it was page 1, and do stuff accordingly. I had a quick go and couldn’t work out how to use it with 2 loops because my knowledge is pretty lacking!

    what do you think Doc? or anyone else that fancies being my hero!?!!?

    Thank you!

    #69357
    Chris Coyier
    Keymaster

    Yeah you gotta check if you are on a paginated page for that first query. Otherwise that first query has no idea and will just grab the most recent post. You don’t need to do that fancy stuff to know if a post is paginated though, you can just:

    Code:
    if ($paged) {
    // do stuff
    }

    The $paged variable is equal to the # of page you are on. So if you are at /page/2, $paged will be 2. You can use that number to offset the query. Like

    Code:
    if ($paged) {
    query_posts(“posts_per_page=1&offset=$paged”)
    }

    That offset parameter will skip the first X posts. You’ll need to adjust as needed. As in, if you show 5 posts per page, you’ll need to offset by 6 on page two, so you’ll need to do like:

    Code:
    $offset = (5 * $paged) + 1;

    All covered in Digging Into WordPress — wink wink.

    #78101
    John Tanedo
    Member

    got similar issue on my blog … http://makeyourtheme.com/blog it just doesn’t work here is my codes

    Code:

    id=”post-“>

    Posted on: at

    by:





    hope someone can help. . . i got the dig-wp book btw but dont know which chapter to get around this problem is it page 95?

    #79029
    hoss9009
    Member

    Here’s my code…
    I have the first post looking different ONLY on the first page… I use pagenavi for pagination.

    #88843

    I need some help with this too…links keep reverting back to the new entries and not the older ones.

    I’ve been adding the suggested code above from Chris into my bloghome.php file but its not happening for me.
    blog page is http://vigourdynamicfitness.com.au/blog/&#8230;.can anyone lend a hand =D

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Back End’ is closed to new topics and replies.