1

I have a function in a parent theme:

function cyberchimps_logo_icons() { ?>
<header id="cc-header" class="row-fluid">
    <div class="span7">
        <?php if (function_exists('cyberchimps_header_logo') ) {
            cyberchimps_header_logo();
        } ?>
    </div>  

    <div id="register" class="span5">
        <?php if (function_exists('cyberchimps_header_social_icons') ) {
            cyberchimps_header_social_icons();
        } ?>
    </div>
</header>
<?php }
add_action('cyberchimps_header_content', 'cyberchimps_logo_icons');

I want to remove the social icons by removing the second half of this function. What's the best way to ADD something to a child themes functions.php to over ride this? I tried copying and pasting this into the child themes functions.php file, and deleting what I wanted gone, but the same function name can't be called twice.

1 Answer 1

1

On the init action, remove the action calling their function and enqueue an action calling your (differently named) function, like this:

add_action('init', 'wpse_80107_init');

function wpse_80107_init() {
    // remove parent theme's header content action
    remove_action('cyberchimps_header_content', 'cyberchimps_logo_icons');

    // add child theme's header content action
    add_action('cyberchimps_header_content', 'wpse_80107_logo_icons');

}

function wpse_80107_logo_icons() {
    // your custom code here
}
3
  • what does the last argument in add_filter do? that '20'? Jan 11, 2013 at 0:06
  • a) it's the priority, i.e. when in the list of init actions to fire; b) it's just some copypasta from other code, I'll remove it from my answer as it's probably not needed here :)
    – webaware
    Jan 11, 2013 at 0:08
  • Also, that should really be add_action, not add_filter! Bad copypasta, no doughnut!
    – webaware
    Jan 11, 2013 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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