• pikkabbu

    (@pikkabbu)


    Hi,
    The template I use as a toggle shortcode.

    [toggle title="My title"]All the text I want to hide or show clicking the title[/toggle]

    but…. I can’t have a link within the toggle texted. That is:

    [toggle title="My title"]All the text I want to hide or show clicking the title <a href="https://my_link">READ MORE</a>[/toggle]

    can NOT works, as toggled text is not html considered.

    I had a look to toggle’s plugins and the same happens.

    QUESTION
    Anyone can help and tell how I can include a link within the toggled text ?

    Maybe adding a parameter [ toggle title=”My tile url=”https://my_url ]

    but I have no idea of coding a function.

    This is the code of template’s shortcode function

    function toggle_shortcode($atts, $content = null) {
    
        extract(shortcode_atts(
            array(
                'title' => 'This is your title'
        ), $atts));
    
        $output = '<div class="toggle">';
        $output .= '<a href="#"><span>+</span>'.$title.'</a>';
        $output .= '<div class="box">';
        $output .= do_shortcode($content);
        $output .= '</div><!-- .box (end) -->';
        $output .= '</div><!-- .toggle (end) -->';
    
        return $output;
    }
    add_shortcode('toggle', 'toggle_shortcode');

    Thank you

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to have an url link within toggled text ?’ is closed to new replies.