5

I've been looking for this all day and can't find it.

I'm working on a custom contacts page and I am using the custom post type feature so that I can have more control over it. I'm looking to change the edit page to be a custom template, (example when I go to /wp-admin/post.php?post=1234&action=edit), I want it to show a custom page. I don't need any meta boxes or anything. Perhaps the editor, but near the bottom of the page (not at the default top).

I've found how to remove the meta boxes, but I haven't found how to get a clean slate on the CPT edit page.

function remove_metaboxes(){
    remove_meta_box('postexcerpt', 'obpcontacts', 'normal'); // Excerpt box
    remove_meta_box('commentstatusdiv', 'obpcontacts', 'normal'); // Comment status box
    remove_meta_box('commentsdiv', 'obpcontacts', 'normal'); // Comment box
}
add_action( 'add_meta_boxes', 'remove_metaboxes',11 );

Thoughts on how to create a custom template in the wp-admin edit section for my custom post type?

5
  • 1
  • Don't think so. Read that one hours ago, and it didn't quite explain how to define my own div's to display my custom fields for the edit page. Also, when I set show_ui to false, I lose the whole CPT in my admin menu - also not ideal. Unless I'm just not connecting the dots?
    – Pat
    Aug 31, 2013 at 0:14
  • Yes, if you set the CPT to false you do lose all of the default menus and interfaces. You want a clean slate. That is as clean as it gets. You can then build your own user interface for the CPT.
    – s_ha_dum
    Aug 31, 2013 at 0:45
  • What you are doing above, by the way, is the way to go about removing the parts of the default edit screen that are removable-- not all parts are. That is the problem you are having. Only parts of the edit screen are alterable. You will never get a clean slate. Building from scratch is the only way to remove everything.
    – s_ha_dum
    Aug 31, 2013 at 0:49
  • Yes, exactly what my question is. How do I get to a clean slate? The proposed duplicate you've voted for doesn't help me out too much. Like I said - I'm not connecting the dots on this one.
    – Pat
    Aug 31, 2013 at 1:10

2 Answers 2

6

As far as I know you can remove almost everything except the title h2 tag, and the .postbox-container border. Also note that the #message is not visible by default but can pop up depending on what you do.

When you register your CPT set supports to an empty array.

'supports' => array ('')

Then you can use the following to unset the publish and slug (the slug in not visible by default but it is there under screen options),

function remove_metaboxes(){
    remove_meta_box('slugdiv', 'obpcontacts', 'normal'); // Slug
    remove_meta_box('submitdiv', 'obpcontacts', 'side'); // Publish box
}
add_action( 'add_meta_boxes', 'remove_metaboxes', 11 );

You will be left with a few elements that might need to be removed with javascript:

//jQuery enqueue only on your CPT
.removeClass("wrap");  //remove all CSS
3

If you don't need the functionality (as opposed to hiding the functionality) you can remove it entirely in the list of arguments supplied to register_post_type().

This will only display the title and editor fields.

$args = array(
    'supports' => array( 'title', 'editor' )
); 

Possible supports:

  • 'title'
  • 'editor' (content)
  • 'author'
  • 'thumbnail' (featured image, current theme must also support post-thumbnails)
  • 'excerpt'
  • 'trackbacks'
  • 'custom-fields'
  • 'comments' (also will see comment count balloon on edit screen)
  • 'revisions' (will store revisions)
  • 'page-attributes' (menu order, hierarchical must be true to show Parent option)
  • 'post-formats' add post formats, see Post Formats

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.