WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] On home page wp_link_pages LINK sends user back to homepage. (5 posts)

  1. jabbamonkey
    Member
    Posted 2 years ago #

    On my site, I list the home PAGE contents, and then I have a list of RECENT POSTS at the bottom of my homepage

    The query involves this... `query_posts('posts_per_page='.$numposts.'&order=DESC');
    get_template_part( 'loop', 'special' );`

    There is a problem when someone clicks the OLDER POSTS link at the very bottom of the list of posts... It just reloads the homepage. It sends the user to http://www.mywebsite.com/page/2/ ... but it's the same content as the current homepage (showing the home content above, and the same 4 list of posts below).

    At the bottom of my loop-special.php page (from the get_template_part function above), I see where the link is being generated...

    <div id="nav-below" class="navigation">
    <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
    <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
    </div><!-- #nav-below -->

    So, how do I get the page to show a continuation of the list of recent posts, and not just redirect them to the same homepage???

    Please help.

  2. RichardWPG
    Member
    Posted 2 years ago #

  3. jabbamonkey
    Member
    Posted 2 years ago #

    Um, not sure how that will help.

    I don't need to change the site URL (the site url is fine), I need the pagination to work for the page with the link structure: http://www.mywebsite.com/page/2/

  4. jabbamonkey
    Member
    Posted 2 years ago #

    I tried the following...

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    echo $page;
    query_posts('order=DESC&paged='.$paged);

    On my index page, I get a list of the 10 most recent posts (1-10). The output for $page is 1.

    When I click the OLDER POSTS link, the output I get is 2 ... but the page still shows the first 1-10 posts. It should be showing 11-20. So, for some reason the QUERY_POSTS isn't recognizing the paged variable...

    I've been checking the forums, and there are a TON of posts regarding this ... but none have been solved in over a year. Is this just a drawback of using WordPress?

  5. jabbamonkey
    Member
    Posted 2 years ago #

    I accidentally stumbled onto a solution. One solution works on the homepage, but not on other 'pages' of the site. The second solution below works on other pages, but not the homepage.

    This did NOT work (on the homepage):

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('posts_per_page='.$numposts.'&order=DESC&paged='.$paged);

    This WORKED (but only from the homepage):

    query_posts('posts_per_page='.$numposts.'&order=DESC&paged='.$page);

    (you dont even need to call the $paged variable line)

    Note: the only difference in the query is that the $paged variable is changed to $page. The value of $page is the page that you are currently on. $paged always outputted '1' for some reason.

    Alternatively, this also WORKED (only on the homepage):

    $pagin = get_query_var('page');
    query_posts('posts_per_page='.$numposts.'&order=DESC&paged='.$pagin);

    However, if I go to another page (not the homepage) that also lists recent posts (www.mysite.com/findspage/) ...

    This WORKED on pages (NOT the homepage though)

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat='.$categorynum.'&posts_per_page='.$numposts.'&order=DESC&paged='.$paged);

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags