wordpress - Wordpress show only shortcode without content
问题描述
How to show only the shortcode not contents of a post in wordpress?
Code I am using is:
<?php $post_content = get_the_content(); ?>
<?php if ( has_shortcode( $post_content, '360' ) ) {
echo do_shortcode( $post_content );
} ?>
Now the result is post content together with shortcode generated code, how to show only the shortcode?
解决方案
使用这样的代码
$post_content = get_the_content();
if ( has_shortcode( $post_content, '360' ) ) {
echo do_shortcode("[360]");
}
推荐阅读
- mysql - 每天多个持续时间的 SUM timestampdiff
- python - Python 返回错误“无法分配给函数调用”
- mongodb - 如何让 mongo 正确运行我的 javascript 脚本
- angular - 量角器 - 发生异步回调超时错误时
- python - Bash 到 python 脚本的转换
- php - 无法通过服务器上的 curl 获取数据
- magento - 错误:[未知对象].fireEvent() 中的错误:事件名称:tinymceChange
- java - 将数据从一台计算机发送到连接到同一 WLAN 的另一台计算机
- sql - 如何从多个表中获取“BILL”
- json - 更改 JSON 结构以适合弹性 swifttype