WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm desperating with this odd issue related to Previous and Next post link. I have this single-name.php which is called by this condition in single.php:

if (in_category('mob')) {
  include (TEMPLATEPATH . '/single-mob.php');
} else {
  include (TEMPLATEPATH . '/single-others.php');
}    ?>

single-mob.php contains the following:

<?php get_header('projs'); ?>

<div id="content-mob">
     <?php if (have_posts()) : ?>  
        <?php while (have_posts()) : the_post(); ?> 

        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <div class="proj-titu-mob">
                <?php the_title(); ?>
            <div class="projetox-mob">
                <?php if (function_exists('camera_meta_slideshow')) {
                    $meta_camera = get_post_custom( $post->ID );
                    echo camera_meta_slideshow($meta_camera['camera_meta_slideshow'][0]);

                <div class="intro-mob"></div>
                <div class="entry-content">
                    <div class="lig">
                        <div class="alin-mob"></div>
                        <span style="font-weight:400; color: #101010;">apply to:</span><br><br>
                        <?php $ooutart = get_field('lig_proj', $post_object->ID); ?>
                        <div class="othertitu">
                            <a href="<?php echo get_permalink($ooutroartigo->ID); ?>"><?php echo get_the_title($ooutroartigo->ID); ?></a>

    <?php endwhile; ?>

    <div class="pagination">
     <?php previous_post_link('%link', 'Previous post in category', TRUE); ?>   
         <?php next_post_link('%link', 'Next post in category', TRUE); ?>              

    <?php endif; ?>

    <div class="aocna_proj">
        <div class="alin-mob"></div>
        <div class="officecont">
            <?php get_template_part( 'page', 'office' ); ?>
<?php get_footer(); ?>

My question here is why the "Previous post in category" link appears and not the "Next post in category". I have 10 posts, limited the post per page in settings to 1 - I don't think this has anything to do with it... The camera_meta_slideshow is related to Camera Plugin (this calls a slideshow) and get_field is related to Advanced Costume Fields Plugin. The only thing I can do is to go to previous posts, even in the middle of the post counts.

Thank you for the help you can give here. Best regards, H.

share|improve this question
up vote 0 down vote accepted

Ok this issue was very hard to get fixed. I finally found the solution:

  • Above <?php if (have_posts()) : ?>:


$max_entries_per_page = 0;
$current_page = (get_query_var('paged')) ? get_query_var('paged') : 0;
        query_posts("category_name=mobiliario&showposts=1&paged=" . $current_page)
  • Bellow <?php endwhile; ?>:


<div class="pagination">
   <div class="pagnext"><?php next_posts_link('—›', $max_entries_per_page) ?></div>
   <div class="pagprev"><?php previous_posts_link('‹—', $max_entries_per_page) ?></div>

I don't know if this is a universal solution. For this structure I presented above it is.

Best regards, H.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.