• alan

    (@alan)


    I’ve found in the Wiki these navigation tags but can’t seem to get them to work:

    <?php next_posts(max); ?>
    <?php previous_posts(); ?>
    <?php next_posts_link('label', max); ?>
    <?php previous_posts_link('label'); ?>
    Used by posts_nav_link, below.
    <?php posts_nav_link('separator', 'previous', 'next'); ?>
    Displays navigation showing next and previous pages. This tag must be within “the loop”.
    Parameters:
    ‘seperator’ – string – The seperator between the links. Defaults to ‘ :: ‘.
    ‘previous’ – string – The link text for the previous page. Defaults to ‘« Previous Page’.
    ‘next’ – string – The link text for the next page. Defaults to ‘Next Page »’.

    Would some WP PHP expert please explain how to use these navigation tags?

Viewing 15 replies - 1 through 15 (of 15 total)
  • carthik

    (@carthik)

    >>Would some WP PHP expert please explain how to use these navigation tags? – That disqualifies a lot of people, including me, who are no php experts. I will hazard an answer, though πŸ™‚
    The following, from “START” to “END”, in index.php is what is fondly called “the loop”:
    <?php if ($posts) { foreach ($posts as $post)"START" { start_wp(); ?>
    <?php the_date('','<h2>','</h2>'); ?>
    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(); ?>">" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></h3>
    <div class="meta">Filed under: <?php the_category() ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?></div>
    <div class="storycontent">
    <?php the_content(); ?>
    </div>
    <div class="feedback">
    <?php link_pages('
    Pages: ', '
    ', 'number'); ?>
    <?php comments_popup_link('Comments (0)', 'Comments (1)', 'Comments (%)'); ?>
    </div>
    <!--
    <?php trackback_rdf(); ?>
    -->
    <?php include(ABSPATH . 'wp-comments.php'); ?>
    </div>
    <?php } }"END" else { // end foreach, end if any posts ?>

    If wanted to display reverse $#$ forward on the index page, I would use
    <?php posts_nav_link('$#$', 'reverse', 'forward'); ?>
    just before the </div> on the second last line of the code I have posted above(which is taken from the index.php file).

    tedfox

    (@tedfox)

    I got the same problem too…. and i’m using the latest nightly built. erm. so somehow… plastering
    <?php posts_nav_link() ?>
    returned nothing too. Tat’s as basic and default a code as it gets. Any help??

    Sushubh

    (@sushubh)

    put this:
    <?php posts_nav_link() ?>
    below this:
    ‘<?php } } else { // end foreach, end if any posts ?>
    Sorry, no posts matched your criteria.
    <?php } ?>’

    Thread Starter alan

    (@alan)

    The code, whether inside or outside “The Loop”, returns nothing. It’s like an include file or function is not being…included.

    tedfox

    (@tedfox)

    I agree with Alan
    Once again… state. I’m using the apr 19th nightly.
    I plastered the code all over the php file. Nothing gets echoed out. In or out of the loop. (other support threads says to put it outside, wiki says to put it inside, so i just put it everywhere)
    So I proceed to change the code abit…. maybe i’m just calling it wrongly. but hey!! errors abound.
    So basically the function SHOULD be calling correctly… but nothing is being echoed out. boohoo… :(:(
    *btw… thanks to Sushubh for replying to all my problemetic posts all over the forums*

    Ozh

    (@ozh)

    (Same for me, using 1.02)

    Thread Starter alan

    (@alan)

    I ask Mr. X on his blog and he posted the snippet of code he uses…..evidently I wasn’t using the correct functions. This code works and from within “The Loop”:
    <?php previous_post('%', '&laquo previous', 'no', 'no', 1, '') ?>
    " title="home">home
    <?php next_post('%', 'next &raquo', 'no', 'no', 1, '') ?>

    Sushubh

    (@sushubh)

    ok u do know u have to select post paged from the options menu in the backend?

    tedfox

    (@tedfox)

    Ok. this is going to make me sound real stupid. But I can’t find any post paged options in the options for the lastest build.
    But hey!! Mr X’s code works…. but <?php posts_nav_link() ?> returns blank. Ah wellz. as long as something works!
    Thanks to alan and sushubh and mr X. woot

    Sushubh

    (@sushubh)

    check this option:
    Show the most recent:
    there is a drop down.

    carthik

    (@carthik)

    @tedfox, depending on what version you are running, the posts pages option is at different locations…
    in 1.0.2 it’s under options->other options-> what to show
    in 1.2 latest cvs/nightly it is under options->reading->show the most recent -> drop down menu.
    Take it easy…:)

    Anonymous

    Woo found it!!!
    Love u peeps. Though I still can’t get <?php posts_nav_link() ?> to work. hahaha. BUt hey! i got the options now. heh. And well.. MR X’s code still works. So all’s well!
    Looking forward to learning PHP and helping answer stuff in this forums

    randybrown

    (@randybrown)

    I’ve added:
    <?php posts_nav_link(' :: ', 'previous', 'next'); ?>
    … inside “the loop” at the bottom. The previous/next links are appearing at the end of each post. I want it to appear only at the bottom of the page.
    Any ideas? Thanks.

    Move it outside of the loop. You can put it right before the end of the content div.

    randybrown

    (@randybrown)

    Thanks, rboren. That worked. I’ll see if I can make this change to the wiki docs.
    <rb>

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘How to navigate to “next post/previous post”’ is closed to new replies.