WordPress.org

Ready to get started?Download WordPress

Forums

Short Code Problem (Not parsing?) (6 posts)

  1. TheBrandon
    Member
    Posted 4 years ago #

    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?

  2. TheBrandon
    Member
    Posted 4 years ago #

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

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

    http://www.nwflaa.com/

  3. TheBrandon
    Member
    Posted 4 years ago #

    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

  4. jennherasme
    Member
    Posted 4 years ago #

    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?

  5. ms_webcasa
    Member
    Posted 3 years ago #

    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.

  6. remiturcotte
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic