Forums

Help, my Loop is not working! (14 posts)

  1. JSDavis82
    Member
    Posted 5 years ago #

    so here's the code in my index.php to call my loop:

    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    </div>

    When you click either previous or next entries, the url changes to, for example, http://jeffrey-davis.net/blog/page/2, but does not call the older posts. Any ideas on how to fix this? thanks a bunch!

  2. Otto
    Tech Ninja
    Posted 5 years ago #

    Where's the actual Loop code? Without seeing that, it's difficult to say what's broken.

  3. JSDavis82
    Member
    Posted 5 years ago #

    oh, i thought that was it. i don't think i know where to find the <i>actual</i> loop code then. Where will it be?

  4. moshu
    Member
    Posted 5 years ago #

    Misleading title...
    Your problem is the "next/prev navigation" - not the Loop.

    Deactivate all plugins and see if it works. Activate them one by one and check which one is causing the navigation to break.

    Also, if you have modified the The Loop that might break the next/prev, too.

    [there is something strange going on with the blog: first some list of posts appears at the top for a few seconds, then it disappears...]

  5. JSDavis82
    Member
    Posted 5 years ago #

    oh, sorry, i think i was confused about what "the loop" was then. I tried the fix you suggested and after all plugins were deactivated, the previous/next links still did not work. any other ideas?

    btw, nothing strange with the template. that is a javascript shelf that loads when you first load the page. if you click the "view recent ten" button in the upper right corner, the shelf slides back down.

  6. JSDavis82
    Member
    Posted 5 years ago #

    any other ideas here?

  7. JSDavis82
    Member
    Posted 5 years ago #

    bump. still need help here.

  8. moshu
    Member
    Posted 5 years ago #

    Does it work if you switch to the default or classic theme? If yes - it's a theme issue.
    If it doesn't, somebody has to look into your index file's code.

  9. JSDavis82
    Member
    Posted 5 years ago #

    yes, it does work if i change it to the default theme. any ideas on what the template issue might be? where could I begin to look?

  10. moshu
    Member
    Posted 5 years ago #

    It could be many things:
    plugins, modified Loop(s), wrong template tag.

  11. JSDavis82
    Member
    Posted 5 years ago #

    yikes, would i just be better then to take out the previous | next entries?

  12. mauropr
    Member
    Posted 4 years ago #

    I'm having the same problem...something is not working with my template, although I've used pretty much the same code found in the documentation.

    I've tried 2 ways:

    <?php next_posts_link('« posts mais recentes') ?> · <?php previous_posts_link('posts mais antigos »') ?>

    and

    <?php posts_nav_link(' · ','« posts mais recentes','posts mais antigos »'); ?>

    Both of them shows the "previous" and "next" links, and creates URLs like "mydomain.com/page/3" "mydomain.com/page/2".

    But the content of each is basically the same as the main page "mydomain.com".

    I'm not sure what's going on...tryed to change the template to the default one and it worked. Moved back to my, didn't work again.

    I put the template here, in case anyone could help:
    http://www.feiramoderna.net/blog_template.txt

    I'm not even sure if this is a problem with this file or not. :-P

    I'm using WP 2.2.1, I don't have any plugins activated, and my site leaves here: http://www.feiramoderna.net

  13. mauropr
    Member
    Posted 4 years ago #

    Update: this page template I've copied is not the index.php file. I use another page template for the blog.

    I have 3 main sessions on the site, each one should display only the posts related to a certain category. So, I've used a script to "filter" the posts, before the loop starts.

    <?php query_posts("cat=-25,-35"); ?>

    I've tested removing this line, and renaming the template file as index.php (also removing the first lines of the page, where I define the template name). The "previous / next entries" worked fine.

    So, I assume there is a conflict between this query I'm doing not to show the posts of some categories, and the feature for creating the pages after I reach the limit os posts per page defined in the "Options" panel of the admin area.

    I really need to have these 3 sessions, and to exclude some posts from the list on each page, according to the category they belong. But seems that the "next/previous" have some difficulties to understand me! :-)

    Anythoughts on how I could fix this?

  14. mauropr
    Member
    Posted 4 years ago #

    Moshu provided the answer! :-)

    http://wordpress.org/support/topic/87020?replies=4#post-444035

    Instead of using:
    <?php query_posts("cat=-25,35"); ?>

    Use:

    <?php $page = (get_query_var('paged'))
    ? get_query_var('paged') : 1;
    query_posts("cat=-25,-35&showposts=10&paged=$page");
    ?>

    It works!

Topic Closed

This topic has been closed to new replies.

About this Topic