Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Wordpress中显示计数最多的标签帖子_Wordpress - Fatal编程技术网

在Wordpress中显示计数最多的标签帖子

在Wordpress中显示计数最多的标签帖子,wordpress,Wordpress,我有不同数量的标签。我想在我正在工作的一个网站的主页上创建一个部分,显示来自最流行标签的五篇文章。我在互联网上搜索了解决方案,但找不到任何解决方案。下面是我到目前为止所做的尝试 <?php $tags = get_terms(array( 'taxonomy' => 'post_tag', 'orderby' => 'count', 'order' => 'DESC' )); $args = array( //'cat' => arr

我有不同数量的标签。我想在我正在工作的一个网站的主页上创建一个部分,显示来自最流行标签的五篇文章。我在互联网上搜索了解决方案,但找不到任何解决方案。下面是我到目前为止所做的尝试

<?php
$tags = get_terms(array(
    'taxonomy' => 'post_tag',
    'orderby' => 'count',
    'order' => 'DESC'
));
$args = array(
    //'cat' => array(4,9,10,11,12,13), 
    'tax_query' => array(
        'taxonomy' => 'post_tag',
        'orderby' => 'count',
        'order' => 'DESC'),
    'posts_per_page' => 5);

$query = new WP_Query( $args );
 while ( $query->have_posts() ) : $query->the_post();
?>
<a href="<?php the_permalink(); ?>"><h3><?php the_title(); ?></h3></a>


<?php
endwhile;
wp_reset_postdata();