Due to location constraints, the Tag Cloud widget settings display 30 tags. Can I insert a custom link at the end of the tag cloud? So that I can link to a tag archive page.

Thanks in advance!

1 Answer 1


Yes, you can.

WP_Widget_Tag_Cloud widget uses wp_tag_cloud to generate the tag cloud. And inside that function and at the end of that function you can find this:

 * Filters the tag cloud output.
 * @since 2.3.0
 * @param string $return HTML output of the tag cloud.
 * @param array  $args   An array of tag cloud arguments.
$return = apply_filters( 'wp_tag_cloud', $return, $args );

It means, that you can use this filter to append something to the output.

There are only 2 things you have to take care of:

  1. Check the format of the result, before appending your HTML. One of the formats is array and this is not HTML, so you should not append your link in that case.
  2. Make sure you modify only the proper cloud (which is not a real problem, because most probably you will have only one tag cloud on your site or you will want to modify all of them just to be consistent).

So here's the code:

add_filter( 'wp_tag_cloud', function ( $return, $args ) {
    if ( 'array' != $args['format'] ) {
        $return .= '<a href="<YOUR LINK URL>" class="more"><YOUR LINK CAPTION></a>';

    return $return;
}, 10, 2 );
  • Thank you, the perfect solution!
    – Matthew
    Jun 30, 2019 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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