I am using Shortcode exec php plugin and putting PHP code in a post via Wordpress Posts panel.
add_action( 'wp_loaded', 'echoFunction');
function echoFunction(){
echo "someText";
}
Why doesn't this work? and how do I make it work?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communitywp_loaded
is called long, long before the post content is fetched. Put that code into a plugin.
Also, you shouldn't echo
anything that early. The HTTP headers aren't sent yet on wp_loaded
, so you will get the Headers already sent error, and your user authentication will not work: you cannot log in anymore.