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

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

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

3 Answers

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

<?php
    $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
add comment

Give this a go.

<?php

    $postsPerPage = 10;

    $wp_query = new WP_Query(
        array(
            'posts_per_page' => $postsPerPage,
            'cat'=>ot_option('hp_mid_cat'),                
            'paged'=>$paged
        )
    );

?>

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

share|improve this answer
add comment

For your code this should work:

<?php 
$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
add comment

Your Answer

 
discard

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