This is the simple version of what im trying to accomplish

//add display_name shortcode
function name_shortcode( ){
    return "testshortcode";
function register_shortcodes(){
    add_shortcode('display-name', 'name_shortcode');
add_action( 'init', 'register_shortcodes');

Which isnt working, the short code gets added to a custom post type called email. Grab the content using

$email_body = get_the_content();

And then email it out. But on the email body, i still only see the [display-name] short code text, instead of the quick "testshortcode" i set up.

Eventually if i get this to work, i would like this actually grab the the actual users display name from a wp_user_query loop i have set up in a seperate chron job funtion to send out a list of reminder emails... but one step at a time.

  • You can use do_shortcode for your content.
    – Jevuska
    Mar 25, 2016 at 14:11
  • How would that work? do_shortcode($email_body)?
    – blank473
    Mar 25, 2016 at 14:15

1 Answer 1


get_the_content returns the content as is without processing, it does not pass it through the filters that are used in the_content such as oembeds or shortcodes. This filter is also called the_content ( coincidence )

Instead use this:

$email_body = apply_filters( 'the_content', get_the_content() );
  • I just tested it out, didnt work for me
    – blank473
    Mar 25, 2016 at 12:28
  • the email body also now has all the html being displayed, span tags and what not.... that wasnt showing up before, and the shortcode is still not being translated
    – blank473
    Mar 25, 2016 at 12:43
  • Are you waiting for the init hook to fire before sending the email? More context will be necessary, and it's likely the issue I solved above and the issue you're having now are not the same, although the result is
    – Tom J Nowell
    Mar 25, 2016 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.