WordPress.org

Ready to get started?Download WordPress

Forums

making custom content type show in catrgories pages (1 post)

  1. tombruton
    Member
    Posted 1 year ago #

    I have my custom types showing, the function below is making it work. However on any of the catergorie pages my main menu is not displaying.

    help please

    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','document','page'); // replace cpt to your custom post type
        $query->set('post_type',$post_type);
    	return $query;
        }
    }

Topic Closed

This topic has been closed to new replies.

About this Topic