• thebrandon

    (@thebrandon)


    Hello everyone,

    I’ve recently begun experimenting with the Short Codes in WordPress.

    I’m an experienced PHP programmer but I’m having trouble getting WordPress to parse my codes.

    I am using the “Mystique” theme.

    I have modified the theme/mystique/functions.php to include:

    require_once('lib/settings.php');
    
    require_once('lib/shortcodes.php');
    
    require_once('lib/brandons_shortcodes.php');

    (Brandons_Shortcodes obviously being my test files)

    I have then made a brandons_shortcodes.php file inside the lib directory with this:

    <?php
    
    //Define the function (what you want the shortcode to do)
    function hello(){
    	return 'Hello World! I am a test shortcode! WOOT!';
    }
    
    //Add shortcode. The first value (hw) is how to call the short code, the 2nd value is the function it should execute.
    function add_shortcode('hw', 'hello');
    ?>

    Now whenever I make a new post with [hw] it doesn’t do anything. It just prints “[hw]”

    What am I doing wrong?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter thebrandon

    (@thebrandon)

    I forgot to mention. This is for the site https://nwflaa.com

    Right now I have a “testing shortcodes” post on the front page:

    https://www.nwflaa.com/

    Thread Starter thebrandon

    (@thebrandon)

    Also, these are the plugins I am using:

    Akismet
    All in One SEO Pack
    Bad Behavior
    Calendar
    Exclude Pages from Navigation
    Google XML Sitemaps
    I Like This
    Local Analytics
    My Page Order
    NextGEN Gallery
    Scissors
    SexyBookmarks
    Viper’s Video Quicktags
    WP-Cumulus

    I have the same problem! I installed the same on different servers, one is working the other one not.

    The shortcodes not working on the primary server.

    Did you find a solution?

    Did anyone find a solution? I’m having the exact same problem. I’ve worked with WP quite a while and never seen this happen.

    remiturcotte

    (@remiturcotte)

    Also, these are the plugins I am using:

    Akismet
    All in One SEO Pack
    Bad Behavior
    Calendar
    Exclude Pages from Navigation
    Google XML Sitemaps
    I Like This
    Local Analytics…

    Shortcodes seems to have a conflict with your other plugins… I’ve modified the plugins that doesnt work because of “shortcode”. Instead i use a “add_filter” that looks like this: add_filter( “the_content”, “my_content_replace_function” );

    IMO it’s better even from a performance standpoint because the shortcode lib (wp-includes/shortcodes.php) also uses “add_filter” to render html.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Short Code Problem (Not parsing?)’ is closed to new replies.