I created some shortcodes which I have include into functions.php

This is the shortcode.php code I have used:

// alert box 
function alertBox($atts, $content = null) {
        "bgcolor" => '#ffffff'
    ), $atts));
    return '<div class="alertBox" style="background:'.$bgcolor.'">'.$content.'</div>';

add_shortcode("alertbox", "alertBox");

/*** info box ***/
function infoBox($atts, $content = null) {
        "bgcolor" => '#ffffff'
    ), $atts));
    return '<div class="infoBox" style="background:'.$bgcolor.'">'.$content.'</div>';

add_shortcode("infobox", "infoBox");

All this was included into the functions.php using this line:

include TEMPLATEPATH . '/extras/shortcodes.php';

When working on WAMP (offline) shortcodes work beautifully but online WordPress only spew out the actual tags like this:


I have created many shortcodes, though mostly with copy/paste/refine... Does anyone have an idea as to why this might happen?

  • Are child themes involved? Does WP_DEBUG display any relevant errors? Aug 18, 2011 at 3:21
  • First time i use that :) i get some errorswhich i dont know the meaning of and they all look like this: Notice: Use of undefined constant php - assumed 'php' in ...
    – Sagive
    Aug 18, 2011 at 3:26
  • 2
    can add your errors in your question? it would be helpfull
    – Christophe
    Aug 18, 2011 at 6:59

2 Answers 2


First, change this:

include TEMPLATEPATH . '/extras/shortcodes.php';

...to this:

include ( TEMPLATEPATH . '/extras/shortcodes.php' );

Second, change TEMPLATEPATH to get_template_directory():

include ( get_template_directory() . '/extras/shortcodes.php' );

(The TEMPLATEPATH and STYLESHEETPATH globals are going away eventually.)

Third, make sure you namespace your function names properly. Function names "alertBox()" and "infoBox()" are far too generic.

Beyond that, we probably need to see your error messages.

  • Ok.. going to try those fixes now
    – Sagive
    Aug 18, 2011 at 15:58

Hi sometimes it is a "silly" error . Look at the start of the file - is the bracket "< ? php " correctly entered ? And wherever else you have it?

By the way I always develop and test with wp-debug switched on permanently on my localhost. It is very useful at flushing out errors.

Yea sometimes one has to switch off when playing with someone else's plugin that did not have the same rigour but well worth the effort .

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.