0

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.

1

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
    ) );
?>
|improve this answer|||||
0

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

|improve this answer|||||
0

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

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy