WordPress.org

Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#4693 closed defect (bug) (fixed)

Make get_tags() honour $args

Reported by: jorda Owned by:
Milestone: 2.3 Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

It is currently not possible to customize tag clouds with wp_tag_clouds() (e.g. number of tags) since this function calls get_tags(), which in turn calls get_terms() without using the $args array.

Attached is a simple patch that seems to fix the problem here.

Thank you.

Attachments (2)

honour_args.diff (388 bytes) - added by jorda 13 years ago.
4693-echo.diff (3.7 KB) - added by Otto42 13 years ago.
Patch to allow wp_tag_cloud to not have to echo the results.

Download all attachments as: .zip

Change History (6)

@jorda
13 years ago

#1 follow-up: @DD32
13 years ago

Just another thought here, Is it somehow possible to allow an alternate source for the tags?
I just built a plugin which had a tagcloud in it, and i found the only way to produce the cloud was to copy the code from the tag cloud function into my own, A much better way might be to move cloud generation into a different function that accepts the list of items maybe? That way WP can have a single function that plugins can use to generate a cloud without re-inventing the wheel(Or tag cloud in this case)

@Otto42
13 years ago

Patch to allow wp_tag_cloud to not have to echo the results.

#2 in reply to: ↑ 1 ; follow-up: @Otto42
13 years ago

Replying to DD32:

I just built a plugin which had a tagcloud in it, and i found the only way to produce the cloud was to copy the code from the tag cloud function into my own, A much better way might be to move cloud generation into a different function that accepts the list of items maybe? That way WP can have a single function that plugins can use to generate a cloud without re-inventing the wheel(Or tag cloud in this case)

How about this patch? It will allow the wp_tag_cloud function to be called with echo=false, thus just returning the tag cloud and not outputting it.

#3 in reply to: ↑ 2 @DD32
13 years ago

Replying to Otto42:

How about this patch? It will allow the wp_tag_cloud function to be called with echo=false, thus just returning the tag cloud and not outputting it.

Thats not really what i had in mind.
It seems i got slightly confused, Its wp_generate_tag_cloud which i was thinking of;
It Accepts a list of tags to use to generate the cloud, however can only used to generate Clouds of WP Tags due to this part of the function:(The link is hard coded)

	$counts = $tag_links = array();
	foreach ( (array) $tags as $tag ) {
		$counts[$tag->name] = $tag->count;
		$tag_links[$tag->name] = get_tag_link( $tag->term_id );
	}

I think it should be in a different Ticket though, So if i still havnt managed to make myself clear.. i'll make a new ticket next week.

#4 @ryan
13 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Looks like the original issue is fixed, so resolving.

Note: See TracTickets for help on using tickets.