WordPress.org

Ready to get started?Download WordPress

Forums

Bug in tag clouds? (5 posts)

  1. adamrice
    Member
    Posted 6 years ago #

    I'm trying to hack around with WP 2.3 to add support for its tags to my theme (I previously used UTW). I want a dropdown menu of all tags, sorted alphabetically.

    It seems that I should be able to use wp_tag_cloud('format=array') to build on, but this echos the array, it does not return it, making it impossible to manipulate, or even display properly.

    I've been doing some messing around with a tweaked version of this function, but have not succeeded in returning a usable array.

    thanks in advance for any advice.

  2. adamrice
    Member
    Posted 6 years ago #

    bump

  3. alainS
    Member
    Posted 6 years ago #

    I've tried also format=array trying to help you out with the problem ...it is correct: It just returns "array" text not the tags.

  4. eikep
    Member
    Posted 6 years ago #

    This seems to be still relevant, so here is the solution:

    in wp-includes/category-template.php the function wp_tag_cloud echos the return value, which makes sense if it's a HTML string but not if it's an array.

    So if you replace

    if ( is_wp_error( $return ) )
    		return false;
    	else
    		echo apply_filters( 'wp_tag_cloud', $return, $args );

    with

    if ( is_wp_error( $return ) )
    		return false;
    	else if (is_array($return)) {
    	 return $return;
    	} else {
    		echo apply_filters( 'wp_tag_cloud', $return, $args );
    	}
    }

    (line 234ff) to check if the return value is an array then the array-option works.

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Known issue:
    http://trac.wordpress.org/ticket/5155

    A patch is in that ticket to fix the problem. Hopefully it'll make it into 2.5.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags