• Resolved thetoolman123

    (@thetoolman123)


    Hi there,

    I am trying to add some custom code to my header.

    I have found that the file I need to edit is in /onepress/inc/template-tags.php. This updates when I use this parent file, however I am trying to use a child theme to edit this.

    I have created and activated the child theme, however the changes I am making are not updating.

    I have duplicated the following file, so it is in:
    /onepress-child/inc/template-tags.php

    but I’m not having any luck seeing the changes.

    This is the specific line I am changing:

    <header id="masthead" class="<?php echo esc_attr( join( ' ', $classes ) ); ?>" role="banner">TEST

    Am I doing something wrong here?

    Any ideas would be appreciated. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • longnguyen

    (@longnguyen)

    Hi,

    The files in the folder /onepress/inc/ cannot be overridden as the regular template files. You need to use the action hook onepress_site_start to remove the current function onepress_site_header then add your custom function. See the example below:

    add_action( 'init', function() {
    	remove_action( 'onepress_site_start', 'onepress_site_header' );
    	add_action( 'onepress_site_start', 'custom_onepress_site_header' );
    } );
    
    function custom_onepress_site_header() {
    	$header_width = get_theme_mod( 'onepress_header_width', 'contained' );
    	...
            // grab all code from the function onepress_site_header and start to customize
            
    }

    https://github.com/FameThemes/onepress/blob/master/inc/template-tags.php#L192-L245

    • This reply was modified 4 years ago by longnguyen.
    Thread Starter thetoolman123

    (@thetoolman123)

    Hi,

    Thanks for the reply.

    Great, thanks, I think I have it working now ??

    Really appreciate your help with that

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘creating a child theme – header not updating’ is closed to new replies.