- This topic has 5 replies, 2 voices, and was last updated 6 years, 4 months ago by Tom.
-
AuthorPosts
-
December 14, 2017 at 6:25 pm #449861ninjajay
I’m just wondering if there is a way that I can disable the page header settings from appearing on selected custom taxonomy and post type admin pages?
In another plugin I use (Restrict Content Pro) I can use a filter to stop the plugin’s settings from appearing selected taxonomies. The way it works in RCP is the filter is passed an array of taxonomies, from there I just remove the taxonomies from the array where I don’t want the settings to appear.
Here is what it looks like in RCP:
function exclude_taxonomies_from_rcp( $taxonomies ) { return array_diff( $taxonomies, [ 'team', 'season', 'opposition', 'sponsorship-level' ] ) ; } add_filter( 'rcp_get_restricted_taxonomies', 'exclude_taxonomies_from_rcp', 20 );
December 14, 2017 at 9:14 pm #449925TomLead DeveloperLead DeveloperHey Jay,
Just so I understand, you want to remove the Page Header select dropdown from inside specific taxonomy edit/add pages and from the “Layout” metabox?
Let me know 🙂
December 15, 2017 at 1:30 am #450014ninjajayYes that’s exactly right, custom taxonomies and post types. The only reason I enabled the page header functionality on this site is because I wanted control over the featured image placement.
December 15, 2017 at 2:15 pm #450500TomLead DeveloperLead DeveloperFeatured images are all handled by the Blog module now in Customize > Layout > Blog.
Page Headers only apply when there’s page header content involved.
Either way, you should be able to do this:
add_action( 'init', 'tu_remove_page_header_tax', 20 ); function tu_remove_page_header_tax() { $taxonomies = array( 'one-taxonomy-id', 'another-id' ); foreach ( $taxonomies as $taxonomy ) { remove_action( $taxonomy . '_add_form_fields', 'generate_page_header_tax_new_ph_field' ); remove_action( $taxonomy . '_edit_form_fields', 'generate_page_header_tax_edit_ph_field' ); remove_action( 'edit_' . $taxonomy, 'generate_page_header_tax_save_ph' ); remove_action( 'create_' . $taxonomy, 'generate_page_header_tax_save_ph' ); } $post_types = array( 'one-post-type-id', 'another-one' ); if ( in_array( get_post_type(), $post_types ) ) { remove_action( 'generate_layout_meta_box_menu_item', 'generate_premium_page_header_menu_item' ); } }
December 18, 2017 at 8:04 pm #452585ninjajayThanks so much for the support Tom I’ve disabled the page header add-on. But, it’s great to have the code, I can think of multiple use cases where I’d like to disable the page header settings on CPT’s and Taxonomies.
December 18, 2017 at 10:50 pm #452638TomLead DeveloperLead DeveloperGlad I could help! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.