Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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) {
    extract(shortcode_atts(array(
        "bgcolor" => '#ffffff'
    ), $atts));
    return '<div class="alertBox" style="background:'.$bgcolor.'">'.$content.'</div>';
}

add_shortcode("alertbox", "alertBox");

/*** info box ***/
function infoBox($atts, $content = null) {
    extract(shortcode_atts(array(
        "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 beautifly but online wordpress only spew out the actuall tags like this

[alertbox]Sometext[/alertbox]

I have created many shortcodes tough mostly with copy/paste/refine.. Anyone got an idea as to why this might happen ?

share|improve this question
    
Are child themes involved? Does WP_DEBUG display any relevant errors? –  Annika Backstrom Aug 18 '11 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 SEO Aug 18 '11 at 3:26
2  
can add your errors in your question? it would be helpfull –  krike Aug 18 '11 at 6:59

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
Ok.. going to try those fixes now –  Sagive SEO Aug 18 '11 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 .

share|improve this answer

Your Answer

 
discard

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.