• I am currently using code snippet to hide the title and editor in a custom post type. My only problem is I don’t want to add a new post type every time I want to add another post type. I got this working one post type or all them using ||. This is the function I am using. Does anyone know how I could get the current post type save it as a local var and then set it as the post type to remove support from.

    add_action('init', 'my_rem_editor_from_post_type');
    function my_rem_editor_from_post_type() {
        remove_post_type_support( 'cpt', 'editor');
    	 remove_post_type_support('cpt', 'title');
    	}
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    No, because at that point in the code, you’re not specifying a post to get the post type from.

    Post types can be arbitrary, so no you cannot remove_post_type_support without knowing the post type you want to remove that support from.

    Thread Starter lex713

    (@lex713)

    @otto42 How would I write the code to get the current post type and set it as a variable. Then use the variable as the post type I want to remove support from? Or is this not possible.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Setting var of current post type’ is closed to new replies.