0

I run in this situation where I must create complex contacts page with custom template, custom meta boxes.

I know how to make custom post type, add meta boxes and display all information in custom template. Problem is I don't need 200 contacts pages that custom post type allows, just one.

Is there way to create this page under pages section?

Similar to selecting dropdown template for page just for admin side that changes page meta box structure.

2
  • Ok, answer was pretty easy. It is possible hide, show metaboxes with jquery and make logic based on that.
    – Rooo
    Jun 18, 2014 at 11:30
  • Go on and add an answer! With some code and a explanation. There is even a badge you can earn for that! Jun 18, 2014 at 12:49

1 Answer 1

0

Simlified function, maybe will help someone:

jQuery(document).ready(function($) {
    $("#page_template").change(function() {
        if($('#page_template').val() != 'page-contacts.php') {
            // show the meta box
            $('#postdivrich').show();
        } else {
            // hide your meta box
            $('#postdivrich').hide();
        }
    }).change();         
}); 

Of course it lacks controls what fields will be submitted, because jQuery just hides them. As I am coding it for one-admin user it is not big deal, helps to get cleaner layout. But in other cases it might be dangerous.

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.