jimi-del
jimi-del

Reputation: 133

WordPress custom shortcode does not display some attribute value ​in full

I have a problem with the shortcode, it does not show me the values ​​I enter correctly

For example, this shortcode:

function subscribe_link_att($atts) {
    $default = array(
        'link'=>'',
        'title' => ''
);
    $a = shortcode_atts($default, $atts);

    return 'Follow us on <a href="'.$a['link'].'">'.$a['title'].'</a>';
    return ob_get_clean();

}
add_shortcode('subscribe', 'subscribe_link_att');

It shows me this:

Follow us on <a href="">’sqsqsc</a>

Current Wordpress version: 6.7.1

Upvotes: 0

Views: 43

Answers (1)

Hamza Kingdom Vision
Hamza Kingdom Vision

Reputation: 44

Your provided code does not show where this shortcode is used. By default, the values for "link" and "title" are null so unless you provide it with a new value the shortcode will return null.

try using [subscribe link="https://stackoverflow.com/" title="Stack Overflow"]

Upvotes: 0

Related Questions