最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - WordPress custom shortcode does not display some attribute value ​in full - Stack Overflow

programmeradmin1浏览0评论

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

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

Share Improve this question edited Feb 26 at 12:38 LoicTheAztec 255k24 gold badges397 silver badges443 bronze badges asked Dec 20, 2024 at 19:08 jimi-deljimi-del 1331 gold badge3 silver badges12 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

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/" title="Stack Overflow"]

发布评论

评论列表(0)

  1. 暂无评论