在一个简单字段(自定义字段)内执行简码
问题描述:
我需要你的帮助,正如我在标题中提到的那样,我希望使用简单文本字段内的射击代码作为自定义字段(属于简单字段WordPress插件)现在它不执行到在一个简单字段(自定义字段)内执行简码
[caption]Testing[/caption]
中的HTML格式..while我已经做字幕的回报..
任何解决方案将高度赞赏..here是我想用短代码使用HTML ..
<div class="box_wrap clearfix">
<div clas="heading">
Call to Action
</div>
<div class="box">
</div>
</div>
我知道怎么说ca n我通过在自定义文本字段中对此进行简码来执行此HTML!1
谢谢!
答
当显示the_content,短码API将任何 注册简码解析例如“[myshortcode]”,独立和解析 属性和内容,如果有的话,并通过他们相应 简码处理函数。由 短代码处理程序返回(未回显)的任何字符串将被插入到帖子主体中,而不是自己的短代码 。
。换句话说,你需要申请the_content过滤器,你输出模板内容。
所以不是有这样的代码:
echo get_post_meta(get_the_ID(), 'your_meta_key', true);
使用这个代替:
// Get your custom meta data using get_post_meta() function
$meta_content = get_post_meta(get_the_ID(), 'your_meta_key', true);
// Then we need to apply 'the_content' filter on the $meta_content
echo apply_filters('the_content', $meta_content);
而且你的简码,应考虑在内。如果您已经注册即短码...
了解更多关于:
- Shortcode API here。
- the_content filter here。
- apply_filters() function here.