Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a Custom Post Type called "cities".

Each city has: Name, Population, Coordinates and so forth. I don't want users to be able to add their custom content there (using wp-content editor, HTML or the Visual one).

What's the best approach to this? Should I hide the text editor in CSS and then place (around 30) metaboxes on each page? Would 30 metaboxes hit theme's performance hard compared to normal posts? I'm aiming for tens of thousands of posts, 30 metaboxes each. Any hints?

share|improve this question
    
And also, you can use edit_form_after_title to put fields outside meta boxes. –  brasofilo Oct 28 '13 at 19:42

1 Answer 1

up vote 3 down vote accepted

To create a custom post type without the editor, simply omit 'editor' in the 'supports' argument when you register the custom post type:

$args = array(
    // only title field will be visible
    'supports' => array( 'title' ),
    // other args here...
);
register_post_type( 'cities', $args );

As for your meta data, that is a lot, but I wouldn't say it's too much. And you don't need to create 30 meta boxes for 30 pieces of data, you can render all of the fields in a single meta box.

Think about how you'll need to use that data later- If you need to query and sort on the data via a meta_query, then it should be its own field. But if there's data that will only be displayed but not queried on, you can save that all as an array under a single key:

$data = array(
    'street' => 'fake street',
    'number' => 123,
    'fruit' => 'pears'
);
update_post_meta( $post_id, 'some_data', $data );

WordPress will take care of converting the array to a storable value, and converting it back to an array when the data is loaded.

share|improve this answer
1  
+1. But from a UI perspective, it would be better to register custom meta boxes for the CPT-specific custom meta-data. –  Chip Bennett Oct 28 '13 at 16:30
    
@ChipBennett, do you mean adding 30 different metaboxes using add_meta_box() to my CPT edit page? Or maybe using Metadata API, if so could you explain more? I've never used custom meta-data before. –  Wordpressor Oct 28 '13 at 17:48
    
Yes, I mean using add_meta_box() to add your meta data. –  Chip Bennett Oct 28 '13 at 17:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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