• Resolved jimbob1155

    (@snowcalling)


    Hi there,

    I would like to add/edit taxonomy on a custom post type which is not public.

    Where is the setting to change the default post types to include all post types (not just public).

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hi @snowcalling

    I believe this snippet should do you well for this topic. It will add a callback for a filter we have for the post types to display as options, and merge in the non-public, but NOT the post types that are built in to WordPress. That way you can at least get the custom private post types from your other settings in CPTUI, but also others coming from other plugins in case you want/need those.

    This snippet would go in your active theme’s functions.php file, hopefully as a child theme. If you’d prefer a quick plugin, perhaps because you have a premium theme that gets regular updates, I can do that.

    If you’d prefer to not include other plugins’ post types, I can amend this code to only fetch post types registered by CPTUI as well. Let me know.

    function cptui_support_include_non_public_post_types_for_taxonomies( $post_types, $args, $output ) {
    	$non_public = get_post_types( [
    		'public'   => false,
    		'_builtin' => false,
    	], $output );
    
    	if ( ! empty( $non_public ) ) {
    		$post_types = array_merge( $post_types, $non_public );
    	}
    
    	return $post_types;
    }
    add_filter( 'cptui_get_post_types_for_taxonomies', 'cptui_support_include_non_public_post_types_for_taxonomies' , 10, 3 );
    
Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Type (not public)’ is closed to new replies.