[Support request] I’m not able to remove the footer meta

Home Forums Support [Support request] I’m not able to remove the footer meta

Home Forums Support I’m not able to remove the footer meta

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1922796
    Berto

    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

    #1923168
    David
    Staff
    Customer Support

    Hi there,

    try:

    add_action( 'wp', function() {
      remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
    } );
    #1923202
    Berto

    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

    #1923207
    David
    Staff
    Customer Support

    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.

    #1923213
    Berto

    Ok thank you for your response!

    #1923947
    David
    Staff
    Customer Support
    #1923958
    Berto

    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

    #1924005
    David
    Staff
    Customer Support

    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' );
    } );
    #1924198
    Berto

    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

    #1924455
    David
    Staff
    Customer Support

    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 πŸ™‚

    #1924596
    Berto

    Wow! That was an awesome explanation!

    I’m learning a lot with your help 😊

    Thanks again!
    Berto

    #1924714
    David
    Staff
    Customer Support
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.