Forums

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

Home Forums Back End [Solved] Blog post loop issue

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #29492
    noahgelman
    Participant

    I have a website that has all the new blog posts updates on a "Blog" page. This page isn’t the index. It’s a custom page. I put in a loop to retrieve the posts but for some reason, when you click "View Older Posts" at the bottom, it goes to the next page, the the post are the exact same. You can keep clicking the View Older or View Newer and it’s always the same ones. Can anyone tell me where I went wrong? There’s the loop:

    Code:

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

    Posted in


    Sorry, no posts matched your criteria.

    It’s pretty basic, but I’m missing something somewhere in it.

    #79783
    noahgelman
    Participant

    Any ideas?

    #79787
    Rob MacKay
    Participant

    that is really odd – as I can’t see anything particularly wrong in your code… but I did find this on the issue:

    http://wordpress.org/support/topic/324200

    It seems there are lots of threads around these two functions as well…

    #80044
    noahgelman
    Participant

    No, that page didn’t really seem to help. If you want to see the problem for yourself though, the link is http://relionsupport.com/blog/ and as you can see the previous and the next buttons at the top change the url, but the posts are the same. To give you some more background, the page is a custom page and the code above is the current loop being shown. I have another loop in the sidebar getting the latest post but I don’t think that should be interfering with it because when I remove it, I still have the same problem.

    I think the issue might be the before and next are affecting the url like it’s supposed to, but doesn’t seem to be changing how the loop displays the posts, like they’re unrelated code or something but the syntax seems to be right.

    Can anyone give me a basic loop that should grab posts and I can just alter that to fit? I’ve tried some from the wordpress codex but when I try any of the loops it just displays nothing.

    #80045
    noahgelman
    Participant

    I have been able to get other wordpress loops to work, although without the pagination working as long as I have: <?php query_posts(”); ?> at the top. Does that mean anything to you?

    #80269
    Templar
    Member

    Man, I have the Same problem here and won’t create a different post, so…

    Offline everything works fine, but when I put the files online the <?php the_title(); ?> function gets the title of the Page, not the Posts like the following image: http://yfrog.com/5b99994592j

    As you can see, there’s a featured post (last post) and I’d like to put the older posts below that one. I could increase the number of featured posts on the wp_query – show posts, but this way I can’t add the navigation buttons and the page would be gigantic.

    The featured post code:

    Code:
    <div id="block-blog">

    <?php
    $featured = new WP_Query();
    $featured->query(‘showposts=1’);
    while($featured->have_posts()) : $featured->the_post();

    $wp_query->in_the_loop = true; // This line is added so that the_tags(”) will work outside the regular loop.
    $featured_ID = $post->ID; // We’ll store this here so that we know to skip this post in the main loop
    ?>

    <?php if (get_post_meta($post->ID, ‘large_preview’, true)) { ?>
    <div class="image_block">
    <img src="<?php echo get_post_meta($post->ID, ‘large_preview’, true); ?>" alt="Featured Post" />
    </div>
    <?php } ?>
    <div class="block-blog">

    <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <small>em: <?php the_time(‘d/m/Y’); ?> onde: <?php the_category(‘, ‘); ?> tags: <?php the_tags(”); ?> por: <?php the_author_posts_link(); ?></small>
    <?php the_excerpt();?>
    <a href="<?php the_permalink(); ?>" class="button">Leia Mais...</a>

    </div>

    <?php endwhile; ?>
    </div>

    The rest of the posts:

    Code:
    <div class="block-blog">
    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>

    <? if ($post-<ID != $featured_ID) { ?>

    <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <small>on <?php the_time(‘M d’); ?> in <?php the_category(‘, ‘); ?> tagged <?php the_tags(”); ?> by <?php the_author_posts_link(); ?></small>
    <?php the_content(‘Read More’); ?>
    <div class="separator biggap"></div>

    <? } ?>

    <?php endwhile ?>

    <div id="posts_navigation">
    <?php previous_posts_link(); ?>
    <?php next_posts_link(); ?>
    </div>

    <?php else : ?>

    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn’t here.</p>
    <?php include (TEMPLATEPATH . ‘/searchform.php’); ?>

    <?php endif; ?>

    </div>

    If I could add 10 posts inside the featured and add the navigation (recent – older posts), that would be perfect.

    Well, I hope someone can help us, I’m a bit desperate haha.

    #81028
    noahgelman
    Participant

    Ok, I stumbled onto this other CSS Tricks Forum post with the exact same issue:

    viewtopic.php?f=10&t=8301

    They say the answer there, but I can’t seem to properly apply it to my code. Does anyone have any idea how?

    #81137
    noahgelman
    Participant

    :o :o :o

    It worked!!!
    Finally!!!

    This has been killing me for weeks >.<

    And my boss and the client has been very upset. I had tried two dozen different things to get it to work. Thank you! :D

    I’ve only built a couple sites on WordPress and so I still don’t know some of the ins and outs. I don’t meant to sound so desperate but this thing has been really aggravating.

    Another question if I can ask one? Where would I put in a post limiter? I want it to display 5 at a time. It’s a custom loop so I can’t control it from within the WordPress admin panel (at least I don’t know of a way to).

    #81172
    noahgelman
    Participant

    Thanks a lot for your help.

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