- This topic has 4 replies, 2 voices, and was last updated 2 years, 11 months ago by David.
-
AuthorPosts
-
September 24, 2021 at 6:41 pm #1942121Alan
I have reduced the number of element headers on my site from 245 (which is way too many) down to around 100 (I can’t go lower unless I want the featured images of the WPSP grids to be rectangular as per this page https://www.savacations.com/interests/) to remove a lot of excessive code and use mostly featured images at the suggestion of this forum. In doing so, I just noticed that when I set up one of the new headers for All Pages, it set up the new header on a number of pages that I do not want, for instance all of my hotel pages. See here for an example https://www.savacations.com/destinations/argentina-tours-travel/argentina-accommodations/hotel-tres-reyes/. My question is what is the best way to remove the headers for the pages that I do not want for both speed and code reduction purposes? Is it to use the exclude feature that comes with the headers or some other way? Please let me know.
Thanks,
September 25, 2021 at 6:10 am #1942394AlanAnother way to ask this questions is for speed and coding purposes, is it appropriate to have a number of pages listed under location rules for each header element, rather than having one separate element for each location?
September 25, 2021 at 10:40 am #1942770DavidStaffCustomer SupportHi there,
performance wise, i doubt there is any noticeable difference between a) large number of single elements vs b) a smaller number of headers with a large list of exclusion rules. I think the bigger issue is related to administrating and managing the various elements and there display rules as you add more pages.
My personal approach is to add the following PHP Snippet to your site:
// Generate custom taxonomy for Element Display Rules function element_control_custom_tax() { register_taxonomy( 'element-controls', array( 'post', 'page' ), array( 'label' => __( 'Element Controls' ), 'rewrite' => array( 'slug' => 'element-controls' ), 'hierarchical' => true, 'show_in_rest' => true, ) ); } add_action( 'init', 'element_control_custom_tax' ); // Exclude custom taxonomy from wp_sitemaps add_filter('wp_sitemaps_taxonomies', function( $taxonomies ) { unset( $taxonomies['element-controls'] ); return $taxonomies; } );
This will create a new Custom Taxonomy for Pages and Posts called Element Controls.
This will allow you to create your own Terms that you can assign to Pages and/or Posts and use those terms for your Display Rules.For example lets say you have:
1. a global header element set FOR all pages.
2. pages that you want to exclude the global header element eg, Hotels
3. pages that have a different header element eg. Special Pages.You could create 2 new Element Control Taxonomy Terms:
Hotels
Special PagesThen in your Global Header Element Exclusions you could add Element Controls > Hotel and Element Controls > Special Pages.
Then for your header element for special pages you can set the Header Element Location to Element Controls > Special pages.Now from within the Page Editor, or the Bulk Editor you can set the Element Control Terms for their specific needs.
September 30, 2021 at 6:56 am #1948104AlanThanks. I will speak with my developer about this.
September 30, 2021 at 7:44 am #1948155DavidStaffCustomer SupportYou’re welcome.
For reference this document explains how to add PHP to your site: -
AuthorPosts
- You must be logged in to reply to this topic.