php - How to print custom field value inside shortcode Wordpress
问题描述
I'm trying to print a Custom field value inside the shortcode I have, I tried the following code but it's not working for me ... what's i can do to make it print the value ?
<?php echo [mks_button size="large" title="Download Pdf File" style="rounded" url="(get_field('download_link')<>""?''.get_field('download_link').'':"");" target="_blank" bg_color="#1e73be" txt_color="#FFFFFF" icon="fa-file-pdf-o" icon_type="fa" nofollow="1"]'); ?>
Note: The Value i want to print inside the url Attribute
解决方案
尝试。
$url = get_field('download_link');
if($url){
echo do_shortcode('[mks_button size="large" title="Download Pdf File" style="rounded" url="'. $url .'" target="_blank" bg_color="#1e73be" txt_color="#FFFFFF" icon="fa-file-pdf-o" icon_type="fa" nofollow="1"]');
}
推荐阅读
- powerbi - Power Bi 的实时气泡图
- python - 查找小于系列中特定值的值的比例
- ios - 购买应用内购买时刷新 iOS 应用
- java - 如何在 JFrame 中添加“添加文本”
- php - 登录可以从数据库中获取任何数据,但显示结果“注销帐户”
- c++ - C++ 函数不会正确调用 main
- eclipse - 如何识别是否成功找到 Selenium(POM)中“asserEquals”的值?
- python - 将手指模板数据转换为图像
- html - CSS Grid 布局应该如何在媒体查询断点处重新组织/重新分布?
- ionic3 - 从 Playstore 安装时已发布的应用程序崩溃