1

So I am using the theme of 'Mesmerize'

I have created a child theme but want to change some of the footer php within the child them so when there is a theme update the changes done reverse.

This is my Functions.php in my child theme \wp-content\themes\mesmerize-child

<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;

// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:

if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
    function chld_thm_cfg_parent_css() {
        wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array(  ) );
    }
endif;
add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 );

And below is the code which I need to change but within the child theme. I am needing to change the 'Built with Wordpress' text which I have been able to do just not using the child theme This is the templates-functions.php located within \wp-content\themes\mesmerize\inc

 //FOOTER FUNCTIONS

function mesmerize_get_footer_content($footer = null)
{
    $template = apply_filters('mesmerize_footer', null);

    if ( ! $template) {
        $template = $footer;
    }

    get_template_part('template-parts/footer/footer', $template);

}

function mesmerize_get_footer_copyright()
{
    $copyrightText = __('**Built using WordPress** and the <a target="_blank" href="%1$s" class="mesmerize-theme-link">Mesmerize Theme</a>', 'mesmerize');

    $copyrightText = sprintf($copyrightText, 'http://extendthemes.com/mesmerize');

    $copyright = '<p class="copyright">&copy;&nbsp;' . "&nbsp;" . date_i18n(__('Y', 'mesmerize')) . '&nbsp;' . esc_html(get_bloginfo('name')) . '.&nbsp;' . wp_kses_post($copyrightText) . '</p>';

    return apply_filters('mesmerize_get_footer_copyright', $copyright);
}

I have tried adding templates-functions.php to \wp-content\themes\mesmerize-child\inc with the changes but this did not work. I have looked through the code but can't seem to change this to get it to call the file from the child theme.

Also just for more information here is the footer.php file in the parent themes files.

        <?php mesmerize_get_footer_content(); ?>
    </div>
<?php wp_footer(); ?>
</body>
</html>

Please let me know if you need any more info and any help will be appreciated with what I need to be doing here

Thanks

UPDATE - I HAVE TRIED THE BELOW from it being suggested in comments. I am posting this code of what I have tried so I can get some help with this.

    function change_copyrightText( $copyrightText ){
$copyrightText = __('Built using TEST and the <a target="_blank" href="%1$s" class="mesmerize-theme-link">TEST Theme</a>', 'mesmerize');

    return $copyrightText;
}

add_filter('change_copyrightText', 'change_copyrightText', 10, 1);
  • Any ideas anyone? :) – Harvey Nov 25 '17 at 22:55
  • You can use the filter to modify the footer, if you notice in the copyright function it has a filter called mesmerize_get_footer_copyright you can use that to Modify just the copyright text – Digvijayad Nov 26 '17 at 19:04
  • Hi, I have been able to change the copyright text in the parent theme... but I am wanting to be able to leave the parent theme be as it will change when a theme update is applied. I have tried copying the file where I made the changes to the child theme location but this does not work. So I need a way to make the changes in the child theme rather than the parent theme if that makes sense? – Harvey Nov 26 '17 at 20:22
  • I can see the filter but how would I use this to make the changes I need to do from the child theme? :) – Harvey Nov 26 '17 at 20:24
  • wordpress.stackexchange.com/a/285721/118765 Here is my answers that explains how to use filters, you would use it in your child themes functions.php – Digvijayad Nov 27 '17 at 1:24
2

You have wrong argument for the filter. The first argument of the add_filter is the filter you are hooking up to. In your case it's the mesmerize_get_footer_copyright. The second argument is the Call back function that would run the filter is called.
So change your add_filter to this

add_filter('mesmerize_get_footer_copyright', 'change_copyrightText', 10,1) ;

  • Ahh I see now! So the first filter is what I am wanting to change the details of... the second filter is calling back to the function created earlier in the code! I've got it now! That' great and its working perfectly now! Really good explanation and its helped me understand the code way more clearly now! – Harvey Nov 27 '17 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.