Support » How-To and Troubleshooting » Easy question! The first who anwser win a cookie

Easy question! The first who anwser win a cookie

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Michael


    Forum Moderator

    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:

    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?

    Moderator Michael


    Forum Moderator

    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:



    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..

    Moderator Michael


    Forum Moderator

    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.

    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?

    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

    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?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Easy question! The first who anwser win a cookie’ is closed to new replies.