限制特定标签在Wordpress中的显示
如何限制Wordpress中某个标记的结果?例如,我只想在我的页面中显示标记“Popular”的5个条目。有没有脚本可以放在functions.php中 试着这样使用限制特定标签在Wordpress中的显示,wordpress,function,tags,limit,Wordpress,Function,Tags,Limit,如何限制Wordpress中某个标记的结果?例如,我只想在我的页面中显示标记“Popular”的5个条目。有没有脚本可以放在functions.php中 试着这样使用 <?php $posttags = get_the_tags(); $count=0; if ($posttags) { $output = ''; foreach($posttags as $tag) { $count++; $output .= $tag->
<?php
$posttags = get_the_tags();
$count=0;
if ($posttags) {
$output = '';
foreach($posttags as $tag) {
$count++;
$output .= $tag->name . ' ';
if( $count >4 ) break; //you can limit count here
}
}
echo $output;
?>