WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way I can return the shortcode text instead of the output.

My code function is hooked into 'the_content' and I know if my function contain shortcode it will automatically generate the output. I just want to output shortcode text e.g [gallery]

add_filter( 'the_content', 'show_on_front', 10 );
function show_on_front( $content ) {
   $content .= 'this is example of shortcode : [gallery]';
   return $content;


share|improve this question
up vote 1 down vote accepted

Another way is to use a shortcode to display shortcodes :)

function shortcode_display_handler($atts = array(),$content=null){
    $content = str_replace("[","[",$content);
    $content = str_replace("]","]",$content);
    return $content;


[SH] [gallery] [/SH]
share|improve this answer
Thanks, It's works ! – resa.r Jan 28 '13 at 16:13

If you want to literally echo "this is example of shortcode : [gallery]" with no shortcode processing then give your filter a very high number for a priority:

add_filter( 'the_content', 'show_on_front', 1000 );

That way, it runs after the shortcode processing function runs.

share|improve this answer
Thanks, this is also works. – resa.r Jan 28 '13 at 16:12

Unless I'm somehow misunderstanding the Question, you could just change [gallery] to [[gallery]].

add_filter( 'the_content', 'show_on_front', 10 );
function show_on_front( $content ) {
   $content .= 'this is example of shortcode : [[gallery]]';
   return $content;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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