[wp-hackers] limiting tag clouds to custom post type

Otto otto at ottodestruct.com
Tue Jun 7 18:05:13 UTC 2011


Post types are part of the posts themselves. So you have to query
against the posts table.

The only "efficient" way to do it is going to be with a custom SQL
query. Join the posts table with term_relationships, term_taxonomy,
and terms, selecting based on the custom post type.

-Otto



On Tue, Jun 7, 2011 at 12:36 PM, Joshua Sibelman
<joshua.sibelman at gmail.com> wrote:
> I've been looking for a way to generate a tag cloud limited specifically to a custom post type, but there doesn't seem to be a built-in method for doing this.
>
> I found this:
> http://wordpress.stackexchange.com/questions/14331/get-terms-by-taxonomy-and-post-type
>
> But this seems to me to be incredibly inefficient since it's getting all the posts of the custom type from the database, then querying the database for each post to get its respective taxonomy.
>
> Has anyone here attempted to figure out a means of doing the same thing that's more efficient?
>
> Thanks,
> Josh
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list