WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Codium "Nex page" doesn't work (7 posts)

  1. petersandeen
    Member
    Posted 2 years ago #

    Hi,

    I don't know if it's my fault, but the "Next page" link on the index page doesn't work. It links to this page: http://myhappierlife.com/page/2/ but this page is identical to the first page. I've done some alterations to the code, but I have no clue to what might be the problem.

    My website is: http://myhappierlife.com/
    I'm using the latest version of both the theme and WordPress.

    Any help would be much appreciated!

    Sincerely,
    Peter

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Have you tried:

    - deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    - switching to the Twenty Eleven theme to rule out any theme-specific problems.

    - resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems.

  3. petersandeen
    Member
    Posted 2 years ago #

    Hi,

    thank you for your reply. Switching to another theme (Twenty Eleven) resolves the problem. I tried deactivating the plugins and even deleted all unused ones, but it didn't help. I also did the resetting of the plugins folder, but it didn't help either. So, it seems to be a theme issue.

    Is there something else I could try?

    Here's the code from the index page that creates the "Next page" button.

    <?php if(function_exists('wp_pagenavi')) {
    		wp_pagenavi();
    	} else {?>
    		<div class="navigation mobileoff"><p><?php posts_nav_link(); ?></p></div>
    		 <?php } ?>
    		<div class="navigation_mobile"><p><?php posts_nav_link(); ?></p></div>

    I also tried the "WP-PageNavi" plugin, but the same result. http://myhappierlife.com/page/2/ is still identical to the first page (meaning it shows the most recent posts instead of going to older posts.

    Any advice is appreciated!

    Sincerely,
    Peter

  4. jeffreyvr
    Member
    Posted 2 years ago #

    You might want to try to add this before your loop. Of course, you might want to edit to number of posts to show and maybe the category (cat=catid).

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('posts_per_page=10'.'&paged=' . $paged);

    Hope it works.

  5. petersandeen
    Member
    Posted 2 years ago #

    Thank you for replying.

    I want to make sure I understood correctly. Am I supposed to add "<?php" before the code (and "?>" after it)? If I don't it just shows up as text in the page. And also did you mean it needs to be put right before these lines?

    <?php query_posts("cat=-1"); ?>
    			<?php if (have_posts()) : ?>
    			<?php while (have_posts()) : the_post(); ?>

    The code you wrote does affect the number of posts per page, but didn't solve my original problem. Or did I just implement it incorrectly? You mentioned the catid. Did you mean the first line in my loop code?

    I tried removing the first line of the code above (<?php query_posts("cat=-1"); ?>) but it had no effect. I tried moving your code around the loop code and inside of it, but to no effect (though putting it after the loop code made the index page show the latest post indefinite times).

    Advice is still much appreciated!

    Sincerely,
    Peter

  6. jeffreyvr
    Member
    Posted 2 years ago #

    Your right about the php-tags needed in front of/after the code.

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=-1&posts_per_page=10'.'&paged=' . $paged);?>
    			<?php if (have_posts()) : ?>
    			<?php while (have_posts()) : the_post(); ?>

    This would be the code you need to use.

  7. petersandeen
    Member
    Posted 2 years ago #

    Hi jeffreyvr!

    Thank you so much. The code worked. I didn't know how to "combine" the old code into the new one and therefor implemented it incorrectly.

    Sincerely,
    Peter

    PS. It's wonderful to see there are so many people willing to help others here.

Topic Closed

This topic has been closed to new replies.

About this Topic