• Hi,

    I installed the free version of Astra on two sites that are almost identical, one on my localhost and the second one on a regular server. I didn’t enable the Header Builder on the site in the localhost, but I did on the site on the server.

    I added some custom code using the astra_masthead_content hook on the first one and it works perfectly, but on the second site, where the header builder is enabled, the hook doesn’t work at all.

    I checked the docs and the visual guide but I didn’t different hooks when using the Header Builder. What could be the issue?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @little_bird,

    Are you trying to add something to a specific part of your site? Please share the custom code, and I will try it on my dev site.

    I look forward to hearing from you.

    Thread Starter little_bird

    (@little_bird)

    Hi Herman,

    I need to add a custom search button markup next to the main menu. I know there is a search block on the builder but I need this specific markup that already works perfectly in the site not using the header builder.

    
    function search_menu_button_markup() {
    
            ob_start(); ?>
            <div class="ast-masthead-custom-menu-items search-custom-menu-item">
                <div class="search-special-icon-wrapper" role="search"  tabindex="-1">
                    <div class="search-special-icon-inner">
                        <a href="#" class="search-special-icon" aria-label="Search icon link">
                            <span class="screen-reader-text"><?php __('Search','makingphysicsclear')?></span>
                        </a>
                    </div>
                </div> 
            </div>
            <?php
            $markup = ob_get_clean();
            return apply_filters( 'astra_masthead_get_menu_items', $markup );
    
    }
    
    function search_menu_button() {
            $markup = search_menu_button_markup();
    
            echo $markup;
    }
    
    add_action( 'astra_masthead_content', 'search_menu_button', 25 );

    Hi @little_bird,

    Thanks for sharing the custom code. I tried adding it to my dev site which is still using the old Header/Footer, however, it does nothing. Refer to this video, please.

    I look forward to hearing from you.

    Kind regards,
    Herman ??

    Thread Starter little_bird

    (@little_bird)

    Thanks, for your answer. Along with that code, I also added some CSS using the Astra Font for adding the search icon, without that you can’t see the search icon next to the menu but if you see the code with the code inspector, the additional markup should be there. For me, the code works fine if the header builder is not enabled.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘astra_masthead_content action not working’ is closed to new replies.