Skip Navigation

[Resolved] Hide or remove the option from custom post edit page

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user would like to remove the content template metabox from the post edit screen for his custom post type.

Solution:
This needs a custom code to be done. Choose one of the following codes:

function disable_icl_metabox() {
    remove_meta_box('views_template','press_release','side');
}
add_action('admin_head', 'disable_icl_metabox',99);

Or:

add_filter('wpv_filter_wpv_disable_post_content_template_metabox', function($res, $post){
    if(get_post_type($post) == 'press_release'){
        $res = true;
    }
    return $res;
}, 10, 2);

Change "press_release" with the slug of your custom post type.

Relevant Documentation:
https://developer.wordpress.org/reference/functions/remove_meta_box/

https://premium.wpmudev.org/blog/remove-wordpress-meta-boxes/

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

This topic contains 8 replies, has 2 voices.

Last updated by kelvinL-2 3 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#1652571
Screenshot 2020-06-06 at 3.46.45 PM.png

Dear Sir/Madam,

I have three custom posts and also with custom fields associated. I want to remove the options that not related to the custom post. Refer to attached screenshot, I want to hide both Layout and Slider Options and keep the Press, how can you hide them and how can I get the option name?

Best regards,

Kelvin.

#1652681

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Kelvin and thank you for contacting the Toolset support.

You can hide the meta boxes from the screen options at the top of the page. Check this screenshot hidden link

I hope this helps. Let me know if you have any questions.

#1652689

Dear Jamal,

I think I have to rephrase my question, I don't want to ask client to hide/show the option, I want to remove it.

Best regards,

Kelvin

#1652703

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Kelvin and thank you for your feedback.

Actually, I do not know how to remove the sections "Layout options" and "Slider options". Both of these metaboxes are not provided by Toolset. I suspect that they are provided by the theme. And I suppose that if you activate another theme you won't see them.

You will need to check which component(theme/plugin) is adding these metaboxes, then you can remove them using the remove_meta_box from WordPress.
https://developer.wordpress.org/reference/functions/remove_meta_box/

Check this article too, it explains a bit how to remove metaboxes.
hidden link

Best regards,
Jamal

#1652837
Screenshot 2020-06-07 at 12.56.24 AM.png

Dear Jamal,

Thanks for your reply. May I know-how about the Content Template mext_box? How can I check its id? Is there any doc about this?

Best regards,

Kelvin.

#1652875

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Dear Kelvin,

Of course 🙂 I searched the code for the Toolset Views plugin and I found the definition of that meta box in embedded/inc/views-templates/wpv-template.class.php at line 127.
The id is "views_template".

Best regards,
Jamal

#1655593

Dear Jamal,

I added below code in functions.php but not work

function disable_icl_metabox() {
	global $post;
	remove_meta_box('views_template','press_release','normal');
}
add_action('admin_head', 'disable_icl_metabox',99);
#1655719

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello!

I believe you should use "side" instead of "normal" as the meta box is on the right side of the page, and there is no need for the global $post:

function disable_icl_metabox() {
    remove_meta_box('views_template','press_release','side');
}
add_action('admin_head', 'disable_icl_metabox',99);

I have also known recently, that a built-in Toolset hook is available, the tested the following code on my local test:

add_filter('wpv_filter_wpv_disable_post_content_template_metabox', function($res, $post){
    if(get_post_type($post) == 'press_release'){
        $res = true;
    }
    return $res;
}, 10, 2);

You will need to use "press_release" instead of "page". If it does not work, please allow me temporary access(WordPress+FTP) to your website. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1659877

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.