Is there any way to use shortcode to block the display of the post content?

What I want is to use the shortcode to pull the post content directly from the database, manipulate it, and then display it with the shortcode.

But if I do this, the post content displays twice. Once as it prints normally and again when the shortcode displays it.

Is there any way to use shortcode to stop the_content() from executing?

  • How do you create your shortcode?
    – Jevuska
    Commented Mar 23, 2016 at 12:57
  • Where is your shortcode code and what is the context for which you are showing this content? single.php, page.php etc... or something else?
    – Adam
    Commented Mar 23, 2016 at 12:58
  • The shortcode is in a single post. The shortcode itself is being registered by a custom plugin.
    – ibhhvc
    Commented Mar 23, 2016 at 13:18

1 Answer 1


Instead of use of shortcode, you can get the post content, format them the way you want and display them later.

You can use get_the_content function; which will just retrieve post content in a variable.

    $raw_input = get_the_content();
/*process your content here and store the result in variable
$raw_input = str_replace("No", "Yes", $raw_input);
print $raw_input;

This will print the processed content and you can just comment out the_content() function in your single.php.

  • Just curious but could you do this in a way so you wouldn't have to edit the theme files?
    – thebigtine
    Commented Mar 24, 2016 at 10:43

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.