• I’ve created a child theme along with several new Custom Post Types. The parent theme includes several metaboxes for certain post types, but obviously not on the post types I’ve created.

    Is there a way to add some code to my child theme’s functions.php to modify the parent theme’s $meta_boxes array and include some of the new posts as well? I was thinking this could work by finding the subarray of the specific metabox and altering the object_types entry.

    Or do I need to completely recode that metabox in my child theme?

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • what parent theme are you using?

    Thread Starter chrishuh

    (@chrishuh)

    Oh yeah, it’s called Ryla.
    Thanks

    Moderator bcworkz

    (@bcworkz)

    The answer depends on what you mean by “include some of the new posts as well”. If you mean to get the meta boxes to be available on the post edit screens for your new post types, then simply use add_meta_box() specifying your post type screens with the parent’s callbacks.

    If you mean include your post types with the content within the meta box, you would need to consult with your theme’s authors through their support channel. We cannot advise on this because we cannot access your theme’s source code.

    BTW, my suggestion of using add_meta_box() gets the meta box to appear on your post type’s edit screens, but does not cover saving any data collected by the meta box. Your theme may correctly handle this without modification. If not, you’ll need your own code to do that.

    Thread Starter chrishuh

    (@chrishuh)

    What I’m trying to do is use one of the metaboxes that the parent theme provides on some of the new Custom Post Types that I’ve created, so that’ll include the content of the metaboxes and storing anything adding via them.

    The easy way would be to edit the parent theme’s code to add the new post types into the add_meta_box() function, but that could always change if/when the parent theme is updated.

    While looking through the parent theme again I realised that the theme actually uses CMB to create the metaboxes, which explains why the code looks a little different to the standard add_meta_box function. So I guess it’ll be best to ask a new question under that plugin’s support thread, unless you’re able to move this question over?

    thanks

    Moderator bcworkz

    (@bcworkz)

    Ah! You’ve done some good investigation. Yes, please ask in their dedicated support forum. Unfortunately, plugin support is the one place we are currently unable to move topics. Please start a new topic there. A clean start is probably better anyway.

    Thread Starter chrishuh

    (@chrishuh)

    Will do, thanks for your help

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add parent theme metabox to child theme’ is closed to new replies.