Add icon in Directory Starter header

This topic contains 5 replies, has 3 voices, and was last updated by  Nicolas Antoine 4 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #530118

    Nicolas Antoine
    Free User
    Post count: 37

    Hello support team,

    I have a php function which includes an additional icon in Directory Starter header. It works fine.
    But I included it in the HTML of the theme template, of course it would be better to have it in a php snippet.
    The issue is that I do not find the right hook.

    I would like to do something like this :

    
    function my_icon_in_header() {
     ...
    }
    add_action( 'directory_starter_header', 'my_icon_in_header' );
    

    Do the theme’s header has a hook like do_action( ‘your_theme_header_top’ ); ?

    Many thanks

    #530170

    Alex Rollin
    Moderator
    Post count: 27815

    I will ask the developers to take a look at your topic.

    Thanks

    #530342

    Naveen Giri
    Moderator
    Post count: 1559

    Hi Nicolas ,

    I didnt get which icons you talking about.
    could you please send a screensort or site link will also helpful.

    Regards
    Naveen

    #530759

    Nicolas Antoine
    Free User
    Post count: 37

    Hello Naveen,

    I have recover this piece of code which includes the woocommerce shopping cart icon in the header :

        if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
             $count = WC()->cart->cart_contents_count;
            ?>cart->get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php
            if ( $count > 0 ) {
                ?>
                <span class="cart-contents-count"><?php echo esc_html( $count ); ?></span>
                <?php
            }
                    ?><?php

    I place it in the Directory Starter HMTL (header) and it is working well. Now to prevent this piece of code to disappear when Theme will update, I would like to move the function into a PHP Snippet.

    function my_icon_in_header() {
     ...
    }
    add_action( 'directory_starter_header', 'my_icon_in_header' );

    Do Directory Starter header has a hook like do_action( ‘directory_starter_header’ ); ?

    #530761

    Naveen Giri
    Moderator
    Post count: 1559

    Hi Nicolas,

    If you want to customise header file of directory starter theme.
    you can create a child theme and place the header.php file there with custom code.
    https://developer.wordpress.org/themes/advanced-topics/child-themes/
    https://www.wpbeginner.com/wp-themes/how-to-create-a-wordpress-child-theme-video/

    so even after directory starter theme update. you will not lose the code.

    we already have two hooks, see if you can use them

    
    
    
    function my_icon_in_header() {
     ...
    }
    add_action( 'dt_before_header', 'my_icon_in_header' );
    add_action( 'dt_after_header', 'my_icon_in_header' );
    

    Thanks

    #530773

    Nicolas Antoine
    Free User
    Post count: 37

    Thank you Naveen for the feedback, I will try with that.

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount