Add simple button to Tiny MCE (3 posts)

  1. creativelifeform
    Posted 4 years ago #

    Hi there, just wondering if anyone has a simple plug in or code snippet that can help me achieve this. Basically all I need to do, is wrap a block of text in a div, but this functionality needs to be integrated into the TinyMCE so that the client can easily do it themselves without writing code.

    So basically what I need to do is

    • Add a button to the tiny mce
    • Program the button to have the following functionality:

    Wraps selected text in the following:
    <div id="goToSidebar">selected text</div>

  2. Jackson
    Posted 4 years ago #

    I'd recommend a shortcode

    add_shortcode( 'goto', 'my_goto_function')
    function my_goto_function( $atts, $content ) {
        $out = '<div id="goToSidebar">' . $content . '</div>';
        return $out;

    Then all your client would have to learn is;

    [goto]Selected Text[/goto]

  3. creativelifeform
    Posted 4 years ago #

    Hi Jackson, that's actually a pretty good solution! We've decided to do this via tags however now, so if a post has a specific tag, a specific sidebar element is shown. Thanks for the tip though this might come in handy for something else.

Topic Closed

This topic has been closed to new replies.

About this Topic