views:

47

answers:

1

Hi,

I have a custom page template with code:

<?php 
/*
Template Name: Featured
*/
get_header(); ?>

    <div id="content_box">

        <div id="content" class="posts">
        <img src="http://www.dinneralovestory.com/wp-content/uploads/2010/04/favorites.png" alt="Favourites"/><br clear="all" /><br />

        <?php 
        //The Query
        $my_query = new WP_Query('category_name=favourites');
        if ($my_query -> have_posts()) : 
        ?>

            <?php while ($my_query -> have_posts()) : $my_query -> the_post(); ?>

            <div class="featured_box">
                <div class="featured_thumb">
                    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                </div>
                <div class="featured_content">
<span class="post_title"><?php the_title(); ?></span>
                    <?php the_excerpt(); ?>
                </div>
            </div>  
<br clear="all" /><br />        

            <?php endwhile; ?>

        <?php include (TEMPLATEPATH . '/navigation.php'); ?>

        <?php else : ?>

            <h2 class="page_header center">Not Found</h2>
            <div class="entry">
                <p class="center">Sorry, but you are looking for something that isn't here.</p>
            </div>

        <?php 
        endif; 
        wp_reset_query();
        ?>

        </div>

        <?php get_sidebar(); ?>

    </div>

<?php get_footer(); ?>

The navigation.php file has the previous / next code (it works fine for the standard post pages and archive pages)

navigation.php:

<?php if (is_single()) : ?>

<div class="navigation">
    <span class="previous"><?php previous_post_link('&larr; %link') ?></span>
    <span class="next"><?php next_post_link('%link &rarr;') ?></span>
</div>
<div class="clear whitespace"></div>

<?php else : ?>

<div class="navigation">
    <div class="previous"><?php next_posts_link('&larr; Previous Entries') ?></div>
    <div class="next"><?php previous_posts_link('Next Entries &rarr;') ?></div>
</div>
<div class="clear flat"></div>

<?php endif; ?>

I have set the maximum posts per page to 5, but the page using this theme template wont show the links. Any ideas? What code can i use to get them.

Thankyou

+1  A: 

previous_post_link and next_post_link and the like don't make any sense for Pages. Pages are not ordered by date and time, they are hierarchical. In other words, there is no "next" Page. That doesn't make any sense in that respect.

Your base problem is that you're using a custom Page template to display Posts from a specific Category. This is the wrong way to do it, WordPress has perfectly valid category archives already, which work fine and which expect to display Posts properly.

Long story short: You will never get your Page Template approach to work 100% correctly. It just doesn't work that way. Posts were never meant to be displayed on Pages, and trying to do so only leads to things not working.

Otto