How to make tag post listing page working?


I’m adding tags to posts. Clicking a tag takes you to an overview listing of all posts for that tag. I created this listing by adding template “tag.php”, which includes:

$tag = get_queried_object();
$currentSlug = $tag->slug ;
$args = array(
    'tag'                   =>  $currentSlug,
    'post_type'             =>  array( 'post' ),
    'posts_per_page'        =>  '6',
$recentBlog = new WP_Query( $args ); 

This works and produces a listing for a slug like /tag/subject01. So far so good.
Next thing that I want is to add some content blocks to the tag listing page, like a title and intro text. This should be a normal wordpress page that can be edited by content authors. So I created a new page with slug /tag/. For this page, I can’t select the tag.php template. So I copied template tag.php to page-tag.php, and the new page /tag/ is using template page-tag.php.
The problem that I have is that the new page will only show a list of all posts that have been tagged, regardless of which tag it is. When I go to tag/subject01, the page /tag/ is not showing with my additional content; it just shows the list from the template tag.php.
So my question is, how can I make the listing page show the content for tag/subject01, tag/subject02, etc? Thanks!

, , ams 3 years 2020-03-25T16:52:19-05:00 0 Answers 114 views 0

Leave an answer