I use the following code in my category sidebar to check which tags are used in the category. It works, but only for the first 9 posts (every page displays 9 posts which is normal.) So if a tag is used on post 11 for example that tag doesn’t show. How can I change this code so it also checks for the other posts in this category?

slug);
if (have_posts()) : while (have_posts()) : the_post();
$posttags = get_the_tags();
if ($posttags):
foreach($posttags as $tag) {
if (!in_array($tag->term_id , $tag_IDs)):
$tag_IDs[] = $tag->term_id;
$tag_names[$tag->term_id] = $tag->name;
$tag_slug[$tag->term_id] = $tag->slug;
endif;
}
endif;
endwhile; endif;
wp_reset_query();
$getTag = $_GET["tag"];
if ($getTag == '') {
$tag_showall = 'checked';
}
if (!empty($tag_IDs)){
echo '

Aanbieders

';
echo ' Alles weergeven
';
}
foreach($tag_IDs as $tag_ID){
$checked = $tag_slug[$tag_ID];
echo ' '.$tag_names[$tag_ID].'
';
}
?>

What I tried:

When I change this:
query_posts('category_name='.$yourcat->slug);

to this:
query_posts('category_name='.$yourcat->slug.'&paged='.$paged.'');

and I go to page 2 then it shows the tags from the post from page 2 (which it didn’t do with the first code) so that is a beginning. But it still doesn’t show all the tags from the whole category, but only from the current page.

How can I change my code so that it shows the tags from the whole category?

Read more here: WordPress: query_posts only checks current page instead of whole category for tags


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: