• Hi! In admin, how can I say what custom post type I’m editing?

    I need it mainly because I’m building custom post types with custom meta boxes and want to modify the tinymce editor ONLY fo that specific custom post type creation/edit pages.

    Is an id or name of the custom post type stored somewhere?

    Thank you!

Viewing 1 replies (of 1 total)
  • Thread Starter stratboy

    (@stratboy)

    Found an answer by myself. Anyway, I’d really like if someone could tell me if it’s a good way to achieve my goal or not.

    $post_type = isset($_GET['post_type']) ? $_GET['post_type'] : (isset($_GET['post']) ? get_post_type($_GET['post']) : null );

    I place this code in a funcion called by ‘load-post.php’ and ‘load-post-new.php’ hooks. I can then see if $post_type is == ‘my_custom_post_name’. It works.

    The reason of the chained compressed if statement is that in the ‘post-new.php’ page I’ve got $_GET[‘post_type’], while in the ‘post.php’ page I can’t get it directly (at least it seems so.. There’s no $_GET[‘post_type’]), but I can get the post_type by passing the ID to get_post_type, and I get that ID with $_GET[‘post’].

    OK. So, again, is this a good practice? Am I doing it the right way?

Viewing 1 replies (of 1 total)
  • The topic ‘In admin, how can I say what custom post type I'm editing?’ is closed to new replies.