我需要你的帮助,正如我在标题中所提到的,我想在简单文本字段中使用镜头代码作为自定义字段(属于简单字段WordPress插件)截至目前它尚未执行
[caption]Testing[/caption]
..虽然我已经以HTML格式制作了字幕..
任何解决方案都会得到高度赞赏。我想使用短代码来使用HTML。
<div class="box_wrap clearfix">
<div clas="heading">
Call to Action
</div>
<div class="box">
</div>
</div>
让我知道如何通过在自定义文本字段中对此进行短代码来执行此HTML!1
谢谢!
答案 0 :(得分:0)
当显示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.