• I am attempting to pass a text string into my shortcode:

    [tooltip screen="Test link" popup="Does this test actually work?"]

    This is in my functions.php:

    function wp_tooltip($atts) {
    	extract(shortcode_atts(array(
    		"screen" => '',
    		"popup" => ''
    	), $atts));
    	return '<abbr style="border-bottom: black 1px dashed; cursor: pointer;" title=' . $popup . '>' . $screen . '</abbr>';
    }
    
    if ( function_exists('add_shortcode') )
    	add_shortcode('tooltip', 'wp_tooltip');

    But it doesn’t work because of the spaces in the text string. Any ideas?

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

    (@sfgolfer)

    Further, both the screen link and tooltip includes double quotation marks.

    it seems to work if you surround the strings in your shortcode with single quotes, like so:

    [tooltip screen='"Test link"' popup='"Does this test actually work?"']

    first of all, you get the double quotes shown in the post, and it shows the full tooltip.

    Thread Starter SFGolfer

    (@sfgolfer)

    Yes it does work but I don’t wont quotation marks (single or double) to appear.

    the quotes for the title were missing in the code:
    this should work:

    return '<abbr style="border-bottom: black 1px dashed; cursor: pointer;" title="' . $popup . '">' . $screen . '</abbr>';
    Thread Starter SFGolfer

    (@sfgolfer)

    Nope. Didn’t work either. There’s just something about the quotation marks being used in both the shortcode and function.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Include text string in shortcode’ is closed to new replies.