• I putted a function inside a class and then called it using add_action and the wp_footer hook, like shown below.

    class mwdes_general {
    
      public function __construct() {
        add_action( 'wp_footer', array( $this, 'mwdes_keynav') );
      }
    
      public function mwdes_keynav() {
      // Do something
      }
    
    }

    The code works fine when a single post or a page is opened however for some reason I do not understand it is not executed on the frontpage where the postloop is running. I checked the index file of the theme I’am using and get_footer() is loaded, so I can’t understand why the hook isn’t working.

    When running the function outside the class, it works on both the single and frontpage. Am I missing something here?

  • The topic ‘wp_footer hook not working inside a class if not single’ is closed to new replies.