I need a query to show all posts in the site but not repeat the ones with same tag, I mean only show one post with the same tag.
My current query is
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => array('post'),
'posts_per_page' => 30,
'paged' => $paged,
'order' => 'ASC',
'orderby' => 'name'
);
query_posts($args);
?>
How can I show only post with the same tag?
Thanks!
query_posts
, pretend that function does not exist and useget_posts
orWP_Query
instead, they take exactly the same parameters, but they eliminate a lot of the issuesquery_posts
has for free. Also if your goal is to modify what WP shows, use thepre_get_posts
filter, it's a huge performance boost over what you're doing, and completely eliminates pagination issues