shortcode - May an attribute have no value?

Is it allowed to add an attribute to a shortcode without giving it a value? something like:[shortcode attr1="hasval

Is it allowed to add an attribute to a shortcode without giving it a value? something like:

[shortcode attr1="hasvalue" attr2]

The attribute attr1 has a value, which I can easily catch in a function like: function shortcode( $atts ) {... with $atts['attr1'].

Can I also catch the other attribute attr2? Its value doesn't exist, so $atts['attr2'] is undefined/empty. But can I maybe simply detect if this attribute has been written or not?

This would be useful for binary settings, such as a true or false indication, where it is a bit redundant to write true="true" or something like that.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745145437a4613626.html

相关推荐

  • shortcode - May an attribute have no value?

    Is it allowed to add an attribute to a shortcode without giving it a value? something like:[shortcode attr1="hasval

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信