How do I create a tag.php template that will work for every post that contain tags?
I created few Tags like = Food, Drink and Fruit
post 1 have Food and Drink tags
post 2 have Food and Fruit tags
How do I create a single page for those post of the tags?
My code looks like this, but it didn’t show anything.
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();
}
Please, if anyone knows which part of the code is wrong, tell me.