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

shortcode - May an attribute have no value?

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论