如何创建标记。php模板,将适用于每个包含标签的帖子?
我创建了一些标签,如=食物、饮料和水果
贴子1有食品和饮料标签
帖子2有食物和水果标签
如何为这些标签帖子创建一个页面?
我的代码看起来像这样,但没有显示任何内容。
function get_tags_post($tag_name){
$original_query = $wp_query;
$wp_query = null;
$brand_name= $tag_name;
$args=array(
\'posts_per_page\'=>5,
\'tag\' => $brand_name
);
$wp_query = new WP_Query( $args );
if ( have_posts() ) : while (have_posts()) : the_post();
echo \'<li>\';
single_tag_title();
echo \'</li>\';
endwhile; endif;
$wp_query = null;
$wp_query = $original_query;
wp_reset_postdata();
}
如果有人知道代码的哪一部分是错的,请告诉我。