2014-07-11 63 views
0

嗨,我在wordpress中有这个模板,我想显示10个项目,因为现在在wordpress中的一般选项我有5个项目,但我想用此模板来例外我不知道我需要修改代码,以便在该模板显示10个项目:只显示自定义模板中的10个项目

<?php 
/* 
Template Name: Blog List 
*/ 
?> 
<?php get_header(); ?> 
<div class="content-wrap"> 
    <div class="content"> 
     <?php tie_breadcrumbs() ?> 

<div id="content" class="podcast_archive"> 

     <!--<div class="podcast_full">--> 

      <?php if (have_posts()) : ?> 

       <header><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
        <h1><?php _e('El Jurado del Pueblo' , 'ss-podcasting'); ?></h1> 
       </header> 

       <?php 
       $feed_url = trailingslashit(home_url()) . '?feed=podcast'; 
       $custom_feed_url = get_option('ss_podcasting_feed_url'); 
       if($custom_feed_url && strlen($custom_feed_url) > 0 && $custom_feed_url != '') { 
        $feed_url = $custom_feed_url; 
       } 
       $itunes_url = str_replace(array('http:' , 'https:') , 'itpc:' , $feed_url); 
       ?> 

       <section> 

        <?php 
        /* Start the Loop */ 
        while (have_posts()) : the_post(); ?> 

         <?php 
         $terms = wp_get_post_terms(get_the_ID() , 'series'); 
         foreach($terms as $term) { 
          $series_id = $term->term_id; 
          $series = $term->name; 
          break; 
         } 
         ?> 

         <article class="podcast_episode"> 

          <?php if(has_post_thumbnail()) { ?> 
           <?php $img = wp_get_attachment_image_src(get_post_thumbnail_id()); ?> 
           <a>" title="<?php the_title(); ?>"> 
            <?php the_post_thumbnail('podcast-thumbnail' , array('class' => 'podcast_image' , 'alt' => get_the_title() , 'title' => get_the_title())); ?> 
           </a> 
          <?php } ?> 

          <h3> 
           <strong><?php the_title(); ?></strong> 
           <div class="podcast_meta"><?php echo $series; ?><aside></div> 
          </h3> 

<div id="audio"> 
<?php global $ss_podcasting; 
$enclosure = $ss_podcasting->get_enclosure(get_the_ID()); 
if($enclosure) { 
    $audio_player = $ss_podcasting->audio_player($enclosure); 
    echo $audio_player; 
} ?> 
<?php the_content(); ?> 
</div> 
<div id="audioinfo"> 
<a>">Descargar Audio</a> 
<span class="audiometa"> 
Tamaño: <?php echo get_post_meta(get_the_ID(), 'filesize', true) ?> 
</span> 
</div> 

<?php echo do_shortcode('[divider]');?> 
</article> 
        <?php 
        endwhile; 
        ?> 

       </section> 

      <?php endif; ?> 
<?php wp_pagenavi(); ?> 

      <div class="podcast_clear"></div> 

     </div> 

     <?php comments_template('', true); ?> 
    </div><!-- .content --> 

<?php get_sidebar(); ?> 
<?php get_footer(); ?> 
?> 

我会劝一些,所以我可以自己做:) 非常感谢你

回答

1

你会想在你的循环之前使用query_posts()函数。

global $wp_query; 
$args = array_merge($wp_query->query_vars, array('showposts' => '10')); 
query_posts($args); 

http://codex.wordpress.org/Function_Reference/query_posts

+0

行不通的,显示我的其他类别:(不是模板我有 – alexistkd

+0

遗憾的所有帖子,我没有意识到这是针对特定的查询。新的编辑应该保留你原来的查询,并为你添加showpost限制 –

+0

真棒,非常感谢你 – alexistkd

1

你需要修改模板的查询。我建议使用WP_Query课程。例如:

$args = array( 
    'posts_per_page' => 10 
); 

$the_query = new WP_Query($args); 

if ($the_query->have_posts()) { 

    while ($the_query->have_posts()) { 
     $the_query->the_post(); 
     // Loop item here 
    } 

    wp_reset_postdata(); 

} else { 
    // No results found 
} 
+0

但我怎么能适应我自己的模板? – alexistkd

+0

这是我的循环 \t \t \t \t \t \t \t \t \t \t \t term_id; \t \t \t \t \t \t \t $ series = $ term-> name; \t \t \t \t \t \t \t break; \t \t \t \t \t \t} \t \t \t \t \t \t?> – alexistkd

+0

试试这个http://pastebin.com/qJjVTVe8 – henrywright

1

如果 $args = array( 'posts_per_page' => 10 );

不低于下设置 - 检查在后端工作>阅读有一个“博客网页上显示的最多”如果有5员额比显示只有5个职位。