我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

如何在wordpress中检查该短代码是否为空

I am using the WooCommerce plugin. I created a sale page and use [sale_products] shortcode of WooCommerce. It shows me all sales product perfectly, now I want that if there are no sale products, the message will be show "there is no sale product".

Like this:

if(!empty([sale_products])) {
    [sale_products]
} else {
    // message
}

Is there any way to handle this?

$output = do_shortcode('[sale_products]');
    if($output !== '') {
    [sale_products]
}

近期文章

  • mysql命令不同步(我使用mysql而不是mysqli!)[关闭]
  • 根据分辨率重新定义webView尺寸
  • 从我的wordpage在我的网页上获取最新帖子
  • 自定义css在顶部导航为特定页面wordpress
  • Analytics API和PHP - 以不同格式获取报告
  • 与多模型的laravel关系问题
  • 转换[关闭]时我做错了什么
  • 在laravel中获取具有Eloquent关系的列列表
  • 想通过Opera浏览器提交大量内容
  • PHP / mySQL连接 - 结果中有多个重复的行
  • 不是在HighCharts的列上显示数字
  • php vs javascript处理信息的速度
  • JSON只在解码时返回第一个字符?
  • 从MySQL中选择可变数量的随机记录
  • PHP仅从数组中的一个键获取值
  • 将多维数组值存储到MySQL(PHP)中
  • PHP DomDocument无法处理utf-8字符(☆)
  • 如何以这种方式按字母顺序排列域名列表?
  • 设计问题:如何在线显示用户数量?
  • PHP sql语句搜索数据库中的用户名

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华