The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Need to clarify the usage of add_meta_box in WordPress (6 posts)

  1. Steven
    Posted 5 years ago #

    I have the follwoing code:

    function create_custom_meta_box() {
          add_meta_box( 'Intro', __('Intro'), 'post_intro_meta_box', 'post', 'normal', 'high' );
          add_meta_box( 'Intro', __('Intro'), 'post_intro_meta_box', 'page', 'normal', 'high' );
          add_meta_box( 'RelatedImage', __('Related images'), 'related_images_meta_box', 'post', 'normal', 'high' );
          add_meta_box( 'RelatedImage', __('Related images'), 'related_images_meta_box', 'page', 'normal', 'high' );
          add_meta_box( 'GuestAuthor', __('Guest Author'), 'author_meta_box', 'post', 'normal', 'low' );

    As you can see, I'm using 'Intro' and 'RelatedImage' twice. Is this wrong? Do they have to be unique?

  2. Mark / t31os

    Posted 5 years ago #

    Should be fine since you're adding them to different post types.

    The example shown here uses the same meta box twice (for different post types).

    Are you having problems with the code?

  3. Steven
    Posted 5 years ago #


    It all worked fine until yesterday. Now it's rather unstable. Sometimes it all works, then only data in Related images meta box is saved.

    Even when removing most of my stuff in functions.php and only add one metabox, data is not saved.

    Would be really nice to be able to debug this somehow.

  4. Steven
    Posted 5 years ago #

  5. Mark / t31os

    Posted 5 years ago #

    The two URLs suggested by Michael here give very good examples and still relevant.

    I've not personally worked with adding custom meta boxes, so i'm not really aware of any common problems, i can only suggest following other similar threads and/or tutorials focused on using meta boxes with custom post types.

    I'd assume you already followed an existing example, but if you're having problems with the code i'm not sure what to suggest other than perhaps trying a different method.

  6. Steven
    Posted 5 years ago #

    Thanks, will check it out.
    Yeah. Looked at examplse here, at WP Engineer and some other tutorials.

Topic Closed

This topic has been closed to new replies.

About this Topic