WordPress.org

Ready to get started?Download WordPress

Forums

Tag Cloud & Custom Post Types (6 posts)

  1. luckoskij
    Member
    Posted 3 years ago #

    I am currently creating a portal type website. We have created several custom post types such as wiki, and project which each have their own taxonomies, but they also include the WordPress post_tags, and such. Running the default WordPress tag cloud yields the correct count when hovering over a tag (for example it says 3 posts of category QOTC) however, once you click on it you receive a page where nothing is found unless the category was linked to a post. I have searched through the default-widget.php file and the post-template.php file to no avail. Does anyone know how to make the custom post types display on the output page for the tag cloud? Thanks in advanced.

  2. raquel_p
    Member
    Posted 2 years ago #

    I have the same problem. The links of regular tags doesnt work with Custom Post Types.

    With the regular categories I had the same. But I corrected with code below (in functions.php)

    function any_ptype_on_cat($request) {
    	if ( isset($request['category_name']) )
    		$request['post_type'] = 'any';
    
    	return $request;
    }
    add_filter('request', 'any_ptype_on_cat');

    I created my custom post types built-in categories and tags.

  3. raquel_p
    Member
    Posted 2 years ago #

    I solve with this:

    function any_ptype_on_tag($request) {
    	if ( isset($request['tag']) )
    		$request['post_type'] = 'any';
    
    	return $request;
    }
    add_filter('request', 'any_ptype_on_tag');

    An adaptation of the code above.

    Original Credits:
    http://wordpress.org/support/profile/scribu

  4. luckoskij
    Member
    Posted 2 years ago #

    Thank you very much for your help, it worked perfectly. And for anyone else who needs this information, paste the above codes into the bottom of the functions.php file and it will work. Another one I would add is the following as sometimes the request is category_name and other times it is simply cat. But otherwise it is perfect.

    function any_ptype_on_cate($request) {
    	if ( isset($request['cat']) )
    		$request['post_type'] = 'any';
    
    	return $request;
    }
    add_filter('request', 'any_ptype_on_cate');
  5. indianplayschools
    Member
    Posted 2 years ago #

    Thanks a lot .

  6. iller7
    Member
    Posted 2 years ago #

    Thank you both raquel_p and luckoskij

Topic Closed

This topic has been closed to new replies.

About this Topic