WordPress.org

Ready to get started?Download WordPress

Forums

How to have an url link within toggled text ? (2 posts)

  1. pikkabbu
    Member
    Posted 2 years ago #

    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="http://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="http://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

  2. pikkabbu
    Member
    Posted 2 years ago #

    ┬┐nobody?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags