Easy question! The first who anwser win a cookie (9 posts)

  1. poliquinp
    Posted 3 years ago #

    Where can I find the template for previous_post_link() and next_post_link() ?


  2. a: not a very thematic title :-(

    a useful template file for this would be single.php

    for further inspiration,
    either have a look into loop-single.php of twenty ten (the default theme is always a good source of information)

    or in the codex:

  3. poliquinp
    Posted 3 years ago #

    a : You still win a cookie

    b: I know that I can find it into the single.php.. But what doesn't help me.. I need to enter in the function because I would like to workarround with this.

    Do you know where I could find it?

  4. I need to enter in the function because I would like to workarround with this.

    can you explain what you are trying to achieve?

    do you mean where the functions are defined?



    a useful site to find and follow functions:



  5. poliquinp
    Posted 3 years ago #

    I'm actually trying to let the "previous button" visible event if there is no more "previous Post" and the same for Next.

    My designer did this way..

  6. you could use a conditional with 'get_adjacent_post()' with the appropriate parameters; or with 'get_next_post()'

    'get_next_post()' returns empty if there is no further post in that direction.

    same for 'prev' resp.


    i had dealt with that a while ago.

  7. poliquinp
    Posted 3 years ago #

    Your exemple works pretty well execpt the next/prev doesn't respect my categories..

    I can infinite "next" from all my posts.

    ++ Little problem... My next button stop showing at a moment..

    <div class="left">
    <?php if(get_adjacent_post(false, '', true)) { previous_post_link('%link', '<img src="btn-prev-page.gif">', 'true'); }
    else { echo '<img src="btn-prev-page-disable.gif">'; } ?>
    <div class="right">
    <?php if(get_adjacent_post(false, '', false)) { next_post_link('%link', '<img src="btn-next-page.gif">', 'true'); }
    else { echo '<img src="btn-next-page-disable.gif">'; }  ?>

    Before I was using this line of code to respect my categories

    <div class="right"><?php next_post_link('%link', '<img src="btn-next-page.gif">', 'true') ?></div>

    Do you know why this is happening?

  8. poliquinp
    Posted 3 years ago #

    Ok.. Almost awnser myself..


    <?php get_adjacent_post( $in_same_cat, $excluded_categories, $previous ) ?>


    (boolean) (optional) Whether post should be in same category.

    Default: false

    (string) (optional) Excluded categories IDs.

    Default: ''

    (boolean) (optional) Whether to retrieve previous post.

    Default: true

  9. poliquinp
    Posted 3 years ago #

    The script works fine but when the same post is in two categories, the script goes crazy...

    I can pass from Category X to Y and Z just because the Post is in the three categories, so my Next / Previous become completly useless.

    Any clues how to fix it?

Topic Closed

This topic has been closed to new replies.

About this Topic