I am new to wordpress, I am creating a plugin and for the short code, I am using the short code api. But when I insert this shortcode in my page, it displayes as it is, it does not display the required output. Can asny body tell me what i am doing wrong? Am I calling or creating the function on right place or not? Below is my code

function show_review() {
echo "this is a review form";
add_shortcode('urp_review', 'show_review');

I have created the file named as urp_functions.php in my plugin directory and created the above function. Any help will be appreciated

  • The plugin is activated?
    – kaiser
    Dec 11, 2012 at 8:07
  • yes the plugin is activated Dec 11, 2012 at 8:08
  • Your shortcode cannot work in its current form due to the echo.
    – fuxia
    Dec 11, 2012 at 9:00

2 Answers 2


Your code seems Ok, but is your plug-in correctly installed? You have to upload your urp_functions.php in a folder inside the /wp-content/plugins/ folder and in your urp_functions.php file, you have to insert comments so it gets detected as a plugin. here is the example comment on WordPress codex :

Plugin Name: Magic Plugin
Plugin URI: http://example.com/magic-plugin
Description: Magic Plugin performs magic
Version: 2.3
Author: Mr. Magic
Author URI: http://example.com/

Then once you have done this, you still have to go inside your admin panel and activate the plugin! Have you done all this?

  • no my urp_functions.php file don't have comments :( Dec 11, 2012 at 8:10
  • @user1867912 I just asked you if you have activated your plugin. This means that you A) can see it in the plugins list admin page and therefore B) must have those comments to be visible. => HOW the heck did you activate it without the comments? WP extracts all needed data from those.
    – kaiser
    Dec 11, 2012 at 8:11
  • It might just have been a misunderstanding on what "activate" means. I think it has become clearer now... ;-)
    – barakadam
    Dec 11, 2012 at 8:12
  • @kaiser i mentioned in my comment that my urp_functions.php don't have these comments. Should i add these comments in my urp_functions.php file? Dec 11, 2012 at 8:13
  • 2
    Why is this question marked as the answer in its current form. This is not the solution, it should not be marked as such
    – Tom J Nowell
    Dec 11, 2012 at 9:17

A shortcode is not supposed to echo its content, it's meant to return it


function show_review($atts) {
    return "this is a review form";
add_shortcode('urp_review', 'show_review');

The function is attached to a filter, it filters/processes shortcodes/contents.

If you do an echo, it prints out your code before the content has finished being processed, nevermind displayed.

Perhaps an analogy will help:

Imagine you're eating small cakes on a plate. You go to pick one up and your stomach digests it before it's even an inch above the plate. It needs to follow the process, receive the food inside your body and pass it along to the next organ, rather than doing it the moment anything food related happens.

  • 1
    "Perhaps an analogy will help" ... +1 for being consistent in every place.
    – kaiser
    Dec 11, 2012 at 9:36
  • Who the hell downvoted this and for what reason (aside from being the right answer)?
    – kaiser
    Dec 11, 2012 at 10:38
  • "declares answer wrong, makes no attempt to explain why"
    – Tom J Nowell
    Dec 11, 2012 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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