I created the tag.php page and when I click on a tag on the page of a post it takes me to the tag.php page with the URL of the tag, for example: / tag / wordpress-1 /.
I want to show all the posts of a the tags without having to set all of them.
'tag' => 'post_tag' did not work, it shows nothing on the page.
But when I set the tag. For example 'tag' => 'wordpress-1' it shows all posts with this tag, but I do not want to have to set all tags, I want it to be automatic.
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_type' => 'post', 'posts_per_page' => 9, 'paged' => $paged, 'tag' => 'post_tag' );
$wp_query = new WP_Query($args);
while ( have_posts() ) : the_post(); ?>
<div class="noticia-index">
<a href="<?php the_permalink(); ?>">
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<div class="post-thumbnail" style="background: url('<?php echo $backgroundImg[0]; ?>'); background-size: cover; background-position: center;">
</div></a>
<div class="noticia-index-conteudo"><a href="<?php the_permalink(); ?>"><h2 class="noticia-titulo"><?php the_title(); ?></h2></a>
<div class="subtitulo-noticia"><?php the_excerpt(); ?></div>
<span><img src="<?php echo get_stylesheet_directory_uri(); ?>/img/icones/calendar1.svg" class="calendar"></span>
<span class="date"><?php echo get_the_date(); ?></span>
<span><img src="<?php echo get_stylesheet_directory_uri(); ?>/img/icones/clock1.svg" class="clock"></span>
<span class="time"><?php the_time(); ?></span>
<span><img src="<?php echo get_stylesheet_directory_uri(); ?>/img/icones/bubble2.png" class="bubble"></span>
<span class="disqus-comment-count comments" data-disqus-url="<?php the_permalink(); ?>#disqus_thread"></span>
<a class="leia-mais" href="<?php the_permalink(); ?> ">Leia mais...</a>
</div>
</div>
<?php endwhile; ?>
<!-- Links de paginação -->
<?php echo paginate_links( array(
'prev_text' => '<span>Anterior</span>',
'next_text' => '<span>Próxima</span>'
));
?>