hooks – wp_footer content appearing in admin area


That’s because you’re not using `add_action correctly, what you’ve written is functionally the same as this:

function xyz_footer_print() {
    echo 'footer script here';
$value = xyz_footer_print();
add_action( 'wp_footer', $value );

xyz_footer_print() immediately runs the function and returns nothing. As a result your add_action call says that on the wp_footer even, do nothing.

So you actually have 2 problems not 1, and if you check your PHP error log or install a tool such as query monitor/debug bar you’d see the warning/notice.

Instead actions always take the form:

add_action( 'action name', 'callable type value, aka the name of function to run when the action happens' );

That should give you enough information to fix this, but, it’s the wrong way to put javascript in your footer. You should instead use a JS file and enqueue it the way webelaine suggested.

Badger 1 year 2022-11-10T09:05:46-05:00 0 Answers 0 views 0

Leave an answer