treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress Shortcode Madness!!

  • Ok... back-story... I need to have dynamic modal dialog boxes. Click a word in a Wordpress post and up pops a modal dialog with more information about that word. There are several of these in a page.

    My solution to this was to create a short code that references a post id to get the post content to put in the dialog when it pops up. I'm using the Foundation Theme from Zurb as a starter, and it includes modal dialog code.

    My issue, I'm getting random paragraph tags around my shortcode content. Can anyone tell me what I'm doing wrong????

    What I have in WordPress editor on that page:

    In order to develop a [PopUp id="1"]corporate compensation philosophy[/PopUp], total compensation must be

    What I have my functions.php file

    //Custom PopUp Shortcode for Modal Dialog hottness
    function PopUp($atts, $ShortcodeContent = null) {
    extract(shortcode_atts(array("id" => '5'), $atts));
    $content = parse_shortcode_content( $content );

    global $post;
    $post = get_post($id);
    $postSlug = the_slug($id);
    $myPostContent = $post->post_content;

    return '
    ' . $ShortcodeContent . '

    ' . $ShortcodeContent . ''. $myPostContent . '
    ';
    }
    add_shortcode('PopUp', 'PopUp');

    End result of the above:
    http://www.ebs-consulting.com/Wordpress/consulting-services/human-resources/wage-and-salary-administration/