首页 > 解决方案 > 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?

标签: wordpress

解决方案


使用这样的代码

$post_content = get_the_content();
if ( has_shortcode( $post_content, '360' ) ) {
  echo do_shortcode("[360]");
} 

推荐阅读