Php 在自定义模板中仅显示10项
您好,我在wordpress中有这个模板,我只想显示10个项目,因为现在在wordpress的常规选项中我有5个项目,但我想对这个模板做一个例外,我不知道我必须在哪里修改代码,以便在此模板中显示10个项目:Php 在自定义模板中仅显示10项,php,wordpress,Php,Wordpress,您好,我在wordpress中有这个模板,我只想显示10个项目,因为现在在wordpress的常规选项中我有5个项目,但我想对这个模板做一个例外,我不知道我必须在哪里修改代码,以便在此模板中显示10个项目: <?php /* Template Name: Blog List */ ?> <?php get_header(); ?> <div class="content-wrap"> <div class="content">
<?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(); ?>
?>
“title=”“>
“>描述音频
塔马诺:
?>
我想提出一些建议,这样我就可以自己做了:)
非常感谢您需要修改模板的查询。我建议利用这门课。例如:
$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
}
您需要修改模板的查询。我建议利用这门课。例如:
$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
}
您需要修改模板的查询。我建议利用这门课。例如:
$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
}
您需要修改模板的查询。我建议利用这门课。例如:
$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
}
在循环之前,您需要使用query_posts()函数进行此操作
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'showposts' => '10' ) );
query_posts( $args );
在循环之前,您需要使用query\u posts()函数进行此操作
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'showposts' => '10' ) );
query_posts( $args );
在循环之前,您需要使用query\u posts()函数进行此操作
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'showposts' => '10' ) );
query_posts( $args );
在循环之前,您需要使用query\u posts()函数进行此操作
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'showposts' => '10' ) );
query_posts( $args );
如果
$args=数组(
“每页帖子数”=>10
);代码>
不工作比检查在后端设置->阅读有一个“博客页面显示最多”如果有5篇文章比它只显示5篇文章 如果
$args=数组(
“每页帖子数”=>10
);代码>
不工作比检查在后端设置->阅读有一个“博客页面显示最多”如果有5篇文章比它只显示5篇文章 如果
$args=数组(
“每页帖子数”=>10
);代码>
不工作比检查在后端设置->阅读有一个“博客页面显示最多”如果有5篇文章比它只显示5篇文章 如果
$args=数组(
“每页帖子数”=>10
);代码>
不工作比检查在后端设置->阅读有一个“博客页面显示最多”如果有5篇文章比它只显示5篇文章 但我如何将其适应我自己的模板?这是我的循环,但我如何将其适应我自己的模板?这是我的循环,但我如何将其适应我自己的模板?这是我的循环,但我如何将其适应我自己的模板?这是我的循环不起作用,显示了我其他类别的所有帖子:(不是我拥有的模板抱歉,我没有意识到它是用于特定查询的。新的编辑应该保留您的原始查询,并为您添加showpost限制query\u posts()
不再是真正的推荐。请看这里,Henry,我同意pre\u get\u posts()对于具有多个循环且带有dependent functions.php文件的页面,filter是一个很好的选择,但是对于单个类别页面而言,通过filter而不是直接调用添加功能(对我来说)会让人觉得(过于苛刻了)。在这种情况下,只需保持代码的简单即可。显示我在其他类别的所有帖子时,filter不起作用:(不是我拥有的模板抱歉,我没有意识到它是用于特定查询的。新的编辑应该保留您的原始查询,并为您添加showpost限制query\u posts()
不再是真正的推荐。请看这里,Henry,我同意pre\u get\u posts()对于具有多个循环且带有dependent functions.php文件的页面,filter是一个很好的选择,但是对于单个类别页面而言,通过filter而不是直接调用添加功能(对我来说)会让人觉得(过于苛刻了)。在这种情况下,只需保持代码的简单即可。显示我在其他类别的所有帖子时,filter不起作用:(不是我拥有的模板抱歉,我没有意识到它是用于特定查询的。新的编辑应该保留您的原始查询,并为您添加showpost限制query\u posts()
不再是真正的推荐。请看这里,Henry,我同意pre\u get\u posts()对于具有多个循环且带有dependent functions.php文件的页面,filter是一个很好的选择,但是对于单个类别页面而言,通过filter而不是直接调用添加功能(对我来说)会让人觉得(过于苛刻了)。在这种情况下,只需保持代码的简单即可。显示我在其他类别的所有帖子时,filter不起作用:(不是我拥有的模板抱歉,我没有意识到它是用于特定查询的。新的编辑应该保留您的原始查询,并为您添加showpost限制query\u posts()
不再是真正的推荐。请看这里,Henry,我同意pre\u get\u posts()对于具有多个循环且带有dependent functions.php文件的页面来说,filter是一个很好的选择,但是对于单个类别页面来说,通过filter而不是直接调用添加功能(对我来说)会让人觉得太过分了。在这种情况下,保持代码简单是一个问题。