Home › Toolset Professional Support › [Resolved] Hide or remove the option from custom post edit page
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 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+01:00)
Tagged: How to build a site with Toolset
This topic contains 8 replies, has 2 voices.
Last updated by kelvinL-2 4 years, 8 months ago.
Assisted by: Jamal.
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.
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.
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
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
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
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);
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. **
My issue is resolved now. Thank you!