Since: 1.0 Last Updated:
Back to Main Index

Outputs your custom code before the closing </nav> of the primary header menu and after the pop-in sidebar toggle.

Location: partials/header-centered.php, partials/header-standard.php

Code output appears after:  

Code output appears before:

The following illustration indicates the placement of layers_before_header_nav (A) compared to layers_after_header_nav (B)





This hook is useful for inserting an element into the nav bar such as a search field, linked icon, graphic etc. Note that while elements placed using this hook will inherit the nav styling, they are not inserted into the menu UL and so may require display: inline-block.

This example uses get_search_form() to render the defualt search form inside a custom div, which can be styled in your child theme. To change the content of the form (such as removing labels or setting a specific post type) filter get_search_form.

To place code after/below the <nav>, use layers_after_header_inner

To change the format or content of the menu list itself,  filter wp_nav_menu to provide different arguments.