Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

<?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>
            <div class="projetox-mob">
                <?php if (function_exists('camera_meta_slideshow')) {
                    $meta_camera = get_post_custom( $post->ID );
                if(isset($meta_camera['camera_meta_slideshow'])){
                    echo camera_meta_slideshow($meta_camera['camera_meta_slideshow'][0]);
                            }
                        }
                    ?>
                </div>

                <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>
                        </div>
                    </div>
                </div>

    <?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); ?>              
    </div>

    <?php endif; ?>

    <div class="aocna_proj">
        <div class="alin-mob"></div>
        <div class="officecont">
            <?php get_template_part( 'page', 'office' ); ?>
        </div>
    </div>
<?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
add comment

1 Answer

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()) : ?>:

insert:

<?php 
$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; ?>:

insert:

<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>
</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
add comment

Your Answer

 
discard

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.