← Back
Editing: latest-posts-by-tag.php
<?php function latest_posts_by_tag($tag) { $args = array( 'tag' => $tag, 'posts_per_page' => 3, ); $latest_posts = new WP_Query($args); if ($latest_posts->have_posts()): ?> <div class="tag-link"> <h2><?php echo $tag; ?>:</h2> <a href="/tag/<?php $tag_format = mb_strtolower(iconv('UTF-8', 'ASCII//TRANSLIT', $tag)); echo $tag_format; ?>">Ver mais <?php echo $tag; ?></a> </div> <div class="latest-posts-container"> <div class="first-column"> <?php $latest_posts->the_post(); ?> <div class="post"> <a href="<?php the_permalink(); ?>"> <img src="<?php echo get_the_post_thumbnail_url(); ?>" id="tag-img-col-1" alt="Imagem do post"> <h2 style="font-size: 20px; margin-right: 2px; margin-bottom: 8px" ;><?php the_title(); ?></h2> <p class="p-tag"><?php the_date(); ?></p> </a> <p class="p-tag"> <?php echo get_the_excerpt(); ?> <a style="font-weight : 800; text-decoration-line: underline;" href="<?php the_permalink(); ?>"> Continue lendo ->></a></p> </div> </div> <div class="second-column"> <?php while ($latest_posts->have_posts()): $latest_posts->the_post(); ?> <div class="post"> <a href="<?php the_permalink(); ?>"> <img src="<?php echo get_the_post_thumbnail_url(); ?>" id="tag-img-col-2" alt="Imagem post"> <h2><?php the_title(); ?></h2> <p><?php the_date(); ?></p> </a> </div> <?php endwhile; ?> </div> </div> <?php endif; wp_reset_postdata(); } ?>
Save File
Cancel