Hooks do not work


  • David
    Newbie 21 points
    August 31, 2016 at 3:30 pm

    I just watched Mark Fail youtube video on filters https://www.youtube.com/watch?v=A9NawFvCsKE
    and even after following his instruction it seems that it does not work, what am I doing wrong?

    here is my code in my functions.php in my child theme.

    
    // found this hook on https://www.premiumpress.com/docs/
    // function hook_header($c){ return  apply_filters('hook_header', $c);  }	
    
    function ba_demo( $c ) {
    	
    	$ba_hello_world = "<h1>Hello world!</h1>";
    
    	$c = $ba_hello_world . $c;
    
    	return $c;
    }
    
    add_action( 'hook_header' , 'ba_demo' );
    // add_filter( 'hook_header' , 'ba_demo' );
    
  • zarko
    zarko
    Senior Member 360 points
    August 31, 2016 at 5:21 pm

    hi David

    Try using “hook_header_after” hook instead if you want to add some content after header

    Video which you are watching is for old framework.

    This reply was awarded the best answer by the topic poster.

  • David
    Newbie 21 points
    August 31, 2016 at 5:26 pm

    ok hold off on answering this, sorry

  • zarko
    zarko
    Senior Member 360 points
    August 31, 2016 at 5:28 pm

    No problem, and “hook_header_after” is action hook actually, not a filter, so you will need to print the content like:

    $ba_hello_world = "<h1>Hello world!</h1>";
    
    $c = $ba_hello_world . $c;
    
    echo $c;
    

  • David
    Newbie 21 points
    November 16, 2016 at 8:15 pm

    worked great, thank you kind sir.

Viewing 5 posts - 1 through 5 (of 5 total)

New Business Themes for WordPress 2020

Start your new website today!

View Business Themes