Archived topic
I'm not able to remove the footer meta
11 replies · Started by Berto on September 8, 2021
Hi there,
I'm developing a child theme where I want to have my own author box. For that purpose I want to remove the footer tags completly.
Following your documentation on similar problems and analyzing the code of the parent theme, this snippet should work:
add_action('after_setup_theme', function () {
remove_action('generate_after_entry_content','generate_footer_meta');
}
... but it doesn't
Why? How can I get it to work?
Thanks in advance,
Berto
Hi there,
try:
add_action( 'wp', function() {
remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
} );
That worked, awesome!
By the way, what is the reason it does work this way but not the other way (may be of interest to other people too).
Kind Regards,
Berto
Hooks are fired in a set sequence - you can see them here:
https://codex.wordpress.org/Plugin_API/Action_Reference
Some of the hooks in GP like generate_after_entry_content are fired after the after_setup_theme is fired.
So by moving to the WP hook allows us to override any changes made earlier.
Ok thank you for your response!
You're welcome
Hi again,
Finally, for a clean solution, I will need to remove the meta entry header (... class="entry-meta" ...) and build it by myself.
I tried out this:
remove_action( 'wp', 'generate_add_post_meta', 5 );
And this:
remove_action( 'generate_after_entry_title', 'generate_post_meta');
Both it didn't work
How can I achive this and what hook would you recommend using for rebuilding it with my own code?
Thanks in advance,
Berto
You can update the code i provided to remove both:
add_action( 'wp', function() {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
} );
Now it worked!
The strange thing is that I already had it within the add_action('wp'... function, but I guess that I got muddled with something 😁
Thank you again!
Berto
I think i did a terrible job of explaining Hooks and there order lol
A very simplified example of how things load:
1. WordPress Init and some other stuff ( including the after_setup_theme hook ) is executed.
... some other stuff happens
2. WordPress then reaches the wp function and one of its functions is to load the correct template files eg. single.php for the page being viewed.
Inside our template we have our Hooks registered eg.
do_action('generate_after_entry_title');
// some other code here
do_action('generate_after_entry_content');
... some other stuff happens
3. Then Later on the Theme or GPP adds a callback to those hooks add_action( 'the_hook', 'the_callback'); eg.
add_action( 'generate_after_entry_title', 'generate_post_meta' );
4. WordPress continues running other functions hooked into wp plus some other stuff.
So by doing this:
add_action( 'wp', function() {
// Do some stuff
} );
We Do some stuff after steps #1, #2 and #3 are finished.
Whereas this hook gets fired before #2 ( and #3 ):
add_action( 'after_setup_theme', function() {
// Do some stuff
} );
So our remove_action is fired before step #3, and then later on GPP is adding something back in :)
Wow! That was an awesome explanation!
I'm learning a lot with your help 😊
Thanks again!
Berto
Glad to hear that !!!