1

I'm trying to remove a function that is defined in my parent theme but can't get it to work. The function I want to remove prints previous/next post navigation.

Here's the function:

add_action( 'generate_after_entry_content', 'generate_footer_meta' );
function generate_footer_meta()
{
if ( 'post' == get_post_type() ) : ?>
    <footer class="entry-meta">
        <?php generate_entry_meta(); ?>
        <?php if ( is_single() ) generate_content_nav( 'nav-below' ); ?>
    </footer><!-- .entry-meta -->
<?php endif;
}

I'm using the remove_action( ); function but I'm not sure which action hook to use.

Here's the code I'm using:

function remove_nav_links() {
remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
}
add_action( 'wp_footer', 'remove_nav_links' );

I've tried a few different action hooks including wp_footer but none have worked.

2

Essentially you want to remove this after it had been added, but before that hook fires. Which is hard to tell in general without knowing when does the parent theme executes this.

Also in often confusing way functions.php of child theme is loaded before that of parent theme. Often makes timing of things counter–intuitive.

The very general practice is that you wait until init hook to run any logic, other than strictly related to the load process. So my guess would be on/around init, but really you should figure out when is it added and decide based on that.

  • Thanks, I tried init and it worked. Should have tried that first! I found this article helpful to gaining a better understanding of action hooks. – jrcollins Jul 20 '17 at 23:40

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.