WordPress.org

Ready to get started?Download WordPress

Forums

Register Post Type With Tags Compatibility (4 posts)

  1. alanchrishughes
    Member
    Posted 2 years ago #

    This is the only thing I've been able to find on this topic, but the thread is closed for some reason, and it isn't working entirely.

    http://wordpress.org/support/topic/register_post_type-not-showing-tags?replies=3

    It does show the tags box when writing your post, and the tag will appear in your tag cloud, but when you click said tag the results page do not include posts from the new post type. Any ideas?

  2. alanchrishughes
    Member
    Posted 2 years ago #

    Never mind, I just found this thread that seems to have done the trick

    http://wordpress.org/support/topic/custom-post-type-tagscategories-archive-page?replies=40

    add_filter('pre_get_posts', 'query_post_type');
    function query_post_type($query) {
      if(is_category() || is_tag()) {
        $post_type = get_query_var('post_type');
    	if($post_type)
    	    $post_type = $post_type;
    	else
    	    $post_type = array('post','cpt'); // replace cpt to your custom post type
        $query->set('post_type',$post_type);
    	return $query;
        }
    }
  3. alanchrishughes
    Member
    Posted 2 years ago #

    But this also breaks my wp_menu

  4. alanchrishughes
    Member
    Posted 2 years ago #

    They have a partial fix lower on that page but it only fixes the wp_menu problem for tag pages, and the category pages still have the problem

    Change this line:

    if(is_category() || is_tag()) {
    -to-
    if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.