OB6.
I found that global header/footer templates with display conditions fail to render in the DOM under two specific scenarios:
- Null Global Queries: On 404 pages or Search Results with no hits, the conditioned elements are stripped from the HTML.
- Loop Contamination: On Search Results with hits, if the results list includes a post/page that is explicitly excluded in the Header/Footer’s condition logic, the Header/Footer fails to render for the entire search results page.
It appears the condition engine is incorrectly evaluating the properties of the loop's contents rather than the global page state.
A link to a Sandbox site where the bug has been reproduced
https://handier-caribou-cf1f40.instawp.site/wp-admin/
Steps required to reproduce the bug:
- Create a Header or Footer Template (Location: Entire Site) with a condition: Post (or page) is not [Specific post/page].
- Test Case 1 (404): Visit a non-existent URL. Result: Header or footer is missing.
- Test Case 2 (Empty Search): Search for a term with no results. Result: Header or footer is missing.
- Test Case 3 (Contaminated Search): Search for a term that includes the excluded Post(s) ID(s) in the results list. Result: Header or footer is missing from the entire Search Results page.
- Test Case 4 (Clean Search): Search for a term that returns results excluding that specific Post ID. Result: Header renders correctly.
In this sandbox, the pages excluded in both the header and footer are 'affiliate links' and 'test page'. You can search for 'test' or 'affiliate' to reproduce the issue in this environment.
Actual Behavior
Global elements are stripped from the DOM if the query is empty or if any item in the search loop triggers an "exclude" condition.
Expected Behavior
Global Headers/Footers should evaluate conditions based on the current view/URL state, not the contents of the Template Content Area loop.
Workaround
Duplicate the header and footer templates twice. Assign one set solely to the Search Results template and the other to the 404 page. This ensures they will render regardless of whether the query is null or not.
OB6.
I found that global header/footer templates with display conditions fail to render in the DOM under two specific scenarios:
It appears the condition engine is incorrectly evaluating the properties of the loop's contents rather than the global page state.
A link to a Sandbox site where the bug has been reproduced
https://handier-caribou-cf1f40.instawp.site/wp-admin/
Steps required to reproduce the bug:
In this sandbox, the pages excluded in both the header and footer are 'affiliate links' and 'test page'. You can search for 'test' or 'affiliate' to reproduce the issue in this environment.
Actual Behavior
Global elements are stripped from the DOM if the query is empty or if any item in the search loop triggers an "exclude" condition.
Expected Behavior
Global Headers/Footers should evaluate conditions based on the current view/URL state, not the contents of the Template Content Area loop.
Workaround
Duplicate the header and footer templates twice. Assign one set solely to the Search Results template and the other to the 404 page. This ensures they will render regardless of whether the query is null or not.