Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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
}
share|improve this answer
    
what does the last argument in add_filter do? that '20'? –  Kegan Quimby Jan 11 '13 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 '13 at 0:08
    
Also, that should really be add_action, not add_filter! Bad copypasta, no doughnut! –  webaware Jan 11 '13 at 0:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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