Navbar below add extra header items

You can add extra elements to the header when using the navbar below Navbar Variant. Below is an example of how to add icons, however, if you wish to add something else just replace the $new_items variable with whatever you desire.

Code Example

/**
 * Navbar below add extra header items.
 *
 * @param string $items Header items.
 */
add_filter( 'conversions_navbar_below_extras', 'navbar_below_add_extra_header_items' );
function navbar_below_add_extra_header_items( $items ) {
    
    // Strip outer list tags.
    $remove_wrapper_tags = array('<ul class="list-inline nav-extras">', '</ul>');
    $items = str_replace( $remove_wrapper_tags, '', $items );
    
    // Turn string into an array.
    $items = explode( '</li>', $items );
    
    // Create new items to add.
    $new_items = array(
        '<li class="list-inline-item"><a class="nav-link" href="#"><i aria-hidden="true" class="fab fa-github"></i><span class="sr-only">github</span></a></li>',
        '<li class="list-inline-item"><a class="nav-link" href="#"><i aria-hidden="true" class="fab fa-twitter"></i><span class="sr-only">twitter</span></a></li>'
    );
    
    // Merge items together.
    $items = array_merge( $items, $new_items );
    
    // Turn array back into a string.
    $items = implode( '', $items );
    
    // Add outer list tags back.
    $open_list_tag = '<ul class="list-inline nav-extras">';
    $close_list_tag = '</ul>';
    $items = $open_list_tag . $items . $close_list_tag;
    
    return $items;
}

Result Example

Get started today!

Conversions is on mission to improve the future of web. Are you ready to join us?

Download