1

我在外部网站中使用 WordPress(带有require_once($_SERVER['DOCUMENT_ROOT'] . '/wp-load.php');

我想加载特定页面并显示内容。

$post = get_post(467, OBJECT);

$content = $post->post_content;
$content = apply_filters('wpautop', $content);
$content = str_replace(']]>', ']]>', $content);
setup_postdata($post); 

...

<article id="post-<?php the_ID(); ?>">
  <div class="entry-content">
    <?php echo $content; ?>
    <?php wp_link_pages( array(
                        'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'tm-polygon' ),
                        'after'  => '</div>',
                        ) );
    ?>
  </div> <!-- .entry-content -->
</article><!-- #post-## -->

...

问题是:页面内容是由可视化作曲家页面构建器插件构建的,输出是纯 vc 代码,而不是渲染内容。

喜欢:[vc_row full_width="stretch_row" css=".vc_custom_1472216323117{margin-top: 0px !important;margin-bottom: 50px !important;padding-top: 170px !important;padding-bottom: 165px !important;background-image: url(http://wp.netzexperten.org/wp-content/uploads/2015/09/section14.jpg?id=469) !important;background-position: center !important;background-repeat: no-repeat !important;background-size: cover !important;}"][vc_column][vc_column_text el_class="section-title" css=".vc_custom_1443428582908{margin-top: -25px !important;margin-bottom: 0px !important;}"]

我希望你能帮助我,克里斯

4

2 回答 2

3

得到它的工作:

WPBMap::addAllMappedShortcodes();
echo apply_filters('the_content', $post->post_content);

要注册 VC 短代码,必须调用以下命令:

WPBMap::addAllMappedShortcodes();

于 2016-09-14T07:13:51.367 回答
3

请试试这个

<?php echo do_shortcode( $post->post_content ); ?>

或者

<?php echo do_shortcode(get_post_field('post_content', $yourpostid)); ?>
于 2016-09-14T03:55:16.867 回答