I’m trying to build a custom page template that will show only pages within a certain category. I’ve been following the get_posts guide on the codex, and have this:
<?php bp_dtheme_content_nav( 'nav-above' ); ?> <?php $insp = array('cat' => 4, 'posts_per_page' => 5, 'offset' => 0, 'orderby' => 'post_date'); $posts = get_posts($insp); ?> <?php if ( have_posts() ) : ?> <?php while (have_posts()) : the_post(); ?> ... etc, etc,
This succeeds in limiting it to just posts in category 4, but only shows a single post in the loop. Does anyone know what I’m doing wrong with this code?
Everything except for the $insp array and the $posts = get_posts is from the default index.php file of my parent theme. Is this in the wrong place? Am I going about this in an ass-backwards way?
- The topic ‘Trying to show posts only in certain category using get_posts but having trouble’ is closed to new replies.