3

I am trying to create a tag cloud that combines different post types. When I do a generic wp_tag_cloud, it only pulls the tag from posts, but if I add the custom post type that I want to include in the args, then it displays tags from those posts. However, if I have the same tag in a post and in a custom post type, it shows up twice, instead of being combined. For example, if I have a tag of "trampolines" in a post and the same tag in a custom post type of portfolio, then the tag cloud will display trampolines twice instead of weighting it as double. Any ideas how I can accomplish this?

<?php $args = array(
'smallest'                  => 8, 
'largest'                   => 18,
'unit'                      => 'pt', 
'number'                    => 450,  
'format'                    => 'flat',
'separator'                 => \\"\n\\  ",
'orderby'                   => 'name', 
'order'                     => 'ASC',
'exclude'                   => null, 
'include'                   => null, 
'topic_count_text_callback' => default_topic_count_text,
'link'                      => 'view', 
'taxonomy'                  => array('post_tag', 'portfolio_tag'), 
'echo'                      => true

); ?>

Tags: &nbsp;<?php wp_tag_cloud( $args ); ?> 
2
  • 1
    I can't reproduce this issue. A tag applied to two separate post types only shows up once in the tag cloud. What I think is happening in your case is one of the tags is a Post Tag (post_tag taxonomy) and the other is a Portfolio Tag (portfolio_tag taxonomy). In this case it makes sense to display the "same" tag for each of the two taxonomies, because they point to different things despite having the same name. Commented Mar 13, 2014 at 22:12
  • Thanks for the explanation. You are right. I just changed the portfolio post type to the post_tag taxonomy.
    – Peter
    Commented Mar 23, 2014 at 23:57

1 Answer 1

1

As John said in his comment, you have two taxonomies with separate terms. If both posts and portfolios are to share tags, instead of using a new taxonomy just extend post_tags to portfolio custom post type :

register_taxonomy_for_object_type( 'post_tag', 'portfolio' );

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.