treehouse : what would you like to learn today?
Web Design Web Development iOS Development

page navigation with query_post in wordpress

  • I have a template page dedicated to a specific category of posts, and I'm trying to offer page navigation within this page - but it's not working :? I'm using WP-PageNavi. Here's what my code looks like:


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

    <div class=\"g320\" id=\"blog\" style=\"margin-left:0\">

    <?php query_posts('cat=13&showposts=5'); ?>

    <?php while (have_posts()) : the_post(); ?>
    <!-- Start Tim Thumb -->
    <?php if ( get_post_meta($post->ID, 'Feature Image', true) ) { ?>
    <div class=\"postthumb\">
    <a href=\"<?php the_permalink(); ?>\" rel=\"bookmark\" title=\"Permanent Link to <?php the_title(); ?>\"><img src=\"<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, \"Feature Image\", $single = true); ?>&h=150&w=150&zc=1\" alt=\"<?php the_title(); ?>\" width=\"150\" height=\"150\" /></a> <h2><a title=\"<?php the_title(); ?>\" href=\"<?php the_permalink() ?>\" style=\"text-decoration:underline;\" rel=\"bookmark\"><?php the_title(); ?></a><span class=\"date\"> - <?php the_date(); ?></span></h2>
    <p class=\"content\"><?php echo excerpt(125); ?> ...</p>
    </div><!-- end postthumb -->

    <?php } ?>

    <!-- End Tim Thumb -->

    <?php endwhile;?>

    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>


    </div><!-- end g320 blog -->


    <?php get_footer(); ?>


    I want to show 5 posts or so on a page, then offer navigation at the bottom. Any ideas what I'm doing wrong here?

    Thanks!
  • Try this <?php query_posts('cat=5&showposts=5&paged=' . $paged); ?> or <?php query_posts("cat=5&showposts=5&paged=$paged"); ?> may this helps you to solve out your problem .