1

I'm using a small code to display a tag list for the current categories like below:

<?php
$custom_query = new WP_Query('posts_per_page=-1&category_name=overnachten');
if ($custom_query->have_posts()) :
while ($custom_query->have_posts()) : $custom_query->the_post();
    $posttags = get_the_tags();
    if ($posttags) {
        foreach($posttags as $tag) {
            $all_tags[] = $tag->term_id;
        }
    }
endwhile;
endif;

$tags_arr = array_unique($all_tags);
$tags_str = implode(",", $tags_arr);

$args = array(
'smallest'  => 12,
'largest'   => 12,
'unit'      => 'px',
'number'    => 0,
'format'    => 'list',
'include'   => $tags_str
);
wp_tag_cloud($args);
?>

It currently displays the tags used by the posts in one certain category. I want to use the above code to display all the tags from the category I'm currently in. How would this be possible, with the above code or a better way?

  • Can I ask what the purpose of this is? It sounds like this is a problem you have with a solution to yet another problem that you haven't mentioned, and that there may be a far better/faster/easier way to do what you're trying to accomplish – Tom J Nowell Dec 3 '14 at 1:53
6

Try referencing the cat query variable like so:

$custom_query = new WP_Query( 
    array( 
        'cat' => get_query_var('cat') 
    ) 
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.