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 getting myself pretty confused. i'm trying to modify a template to show more than one post from the loop.

here is the code from the template

<?php $wp_query = new WP_Query(array('cat'=>ot_option('hp_mid_cat'),'showposts'=>ot_option('hp_mid_num'),'paged'=>$paged)); ?>
        <?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?>
        <?php global $more; $more = 0; ?>

i can't figure out how to edit this to show more than one post. i tried adding more categories, thinking it was just pulling the most recent from each category, but that didn't change anything. i have tried to take out this block and insert some new code but then i get errors of all sorts.

share|improve this question

migrated from stackoverflow.com Jul 4 '11 at 5:48

This question came from our site for professional and enthusiast programmers.

I think you can define posts number from Theme Options panel if so use ot_option('hp_mid_num') as posts_per_page parameter to get more flexible query

final code here

    $wp_query = new WP_Query( array( 
    'posts_per_page' => ot_option( 'hp_mid_num' ), 
    'cat' => ot_option( 'hp_mid_cat' ),
    'paged' => $paged
    ) );
share|improve this answer

Give this a go.


    $postsPerPage = 10;

    $wp_query = new WP_Query(
            'posts_per_page' => $postsPerPage,


The parameters available for WP_Query are here: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

share|improve this answer

For your code this should work:

$postsPerPage = 10;
$wp_query = new WP_Query(array( 'posts_per_page' => $postPerPage,'cat'=>ot_option('hp_mid_cat'),'showposts'=>ot_option('hp_mid_num'),'paged'=>$paged)); ?>
            <?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?>
            <?php global $more; $more = 0; ?>

For more information please check WordPress codex pages: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

share|improve this answer

Your Answer


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