Passing a Variable to a Function Hooked to Genesis Entry Content

If you are going to be setting the notice dynamically, what I would do is just pull in the notice in the callback function. But if you can’t do that for whatever reason, you can do a little wizardry like so:

if( $notice ) {

    remove_action( 'genesis_entry_content', 'genesis_do_post_content' );

    add_action ( 'genesis_entry_content', function() use ($notice) {
        echo $notice;
    }, 5 );

}

This takes advantage of the php use keyword available to anonymous functions.