$args = array(
\'type\' => \'post\',
\'orderby\' => \'name\'
);
$tags = get_tags($args);
foreach($tags as $tag) {
$the_query = new WP_Query( \'tag=\'.$tag->name );
if ( $the_query->have_posts() ) {
$the_query->the_post();
$desired_posts[] = get_the_ID(); // all the post IDs stored here.
} else {
// no posts found
}
wp_reset_postdata();
}
$args1 = array(
\'post_type\' => \'post\',
\'orderby\' => \'date\',
\'post__in\' => $desired_posts,
\'posts_per_page\' => -1
);
$the_query = new WP_Query( $args1 );
echo \'<ul>\';
if($the\\u query->have\\u posts()){而($the\\u query->have\\u posts()){$the\\u query->the\\u post();echo \'<li>\'. get_the_title() . \'</li>\';
} } else{//未找到帖子}echo \'</ul>\';
代码>