Compact ‘pop-out’ search bar placement on specific pages only
Last updated
Last updated
This quick tutorial will help you configure and place a pop-out search bar to the sidebar of your site using a custom code – allowing inclusion or exclusion from specific pages.
For generic use please check the Compact Box Layout documentation (includes a video tutorial).
Make sure to enable the compact box layout mode under the Layout Options -> Compact box layout panel. For this tutorial I recommend the following configuration:
Compact layout final width: 320px
Compact search box position: fixed (or absolute may also work)
Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
Adjustable variables within the code (lines 7-17):
$id -> the search instance ID
$exclude_on_pages -> list of page IDs, where the search should not be visible. Leave it empty, if not in use.
$include_on_pages -> list of page IDs, where the search should be visible. Leave it empty, if not in use.
$exclude_on_archives -> true or false. If true, then then the search will not be visible on post type archives.
$exclude_on_tax_archives -> list of taxonomies. The search will not be visible on listed taxonomy archive pages.
$exclude_on_front -> true or false. If true, the search will not be visible on the front page.
What is this, and where do I put this custom code?