I want to create a custom meta-box for all custom post types: post, page, and every custom post type (portfolio, testimonials, FAQs, quotes, reviews...). But without writing them into the array:

'pages' => array('post', 'page', 'portfolio', 'testimonials', 'FAQs'),

Is it possible to create a general meta-box?

PS: Actually, I just need it because I have a length counter in JS for two meta-boxes, and if a client installs a plugin with new taxonomies, then these taxonomies don't work, only on posts and pages: the add button (of the taxonomy) does nothing because of a conflict. The JS code is ok, but I can paste it here if you think it's important:

function metadesc_count_js() { ?>
    jQuery("textarea#ion_meta_description_tag").after("<div style=\"position:relative;color:#333;font-size:12px;padding-top:3px\"><?php _e('Length: ', 'seozeta'); ?><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"1\" id=\"metadesc_counter\" readonly=\"\" style=\"box-shadow:none;border:none;background:inherit\"></div>");
    jQuery("textarea#ion_meta_description_tag").keyup(function () {


add_action('admin_head-post.php', 'metadesc_count_js');
add_action('admin_head-post-new.php', 'metadesc_count_js');

However, my question here is the title of the question: a custom meta-box for all custom post types.

Edit: At the end, the conflict of the JS in the taxonomies was because I needed to enqueue the JS code in the correct way:

add_action( 'admin_head', 'my_custom_admin_head' );

And I think the Milo's answer will work for the main question.

  • 1
    See this answer. – Milo Jan 20 '15 at 18:20
  • Awesome, thanks. It seems what I was searching. I'm gonna try to implement it on Option-Tree framework. – Gerard Jan 20 '15 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.