我正在编辑一个使用Visual Composer的WordPress主题。在主页上,我正在Visual Composer中集成我自己的自定义新闻馈送。
我使用Insert-PHP插件来允许我在Visual Composer中添加PHP:
[insert_php]include('rm_news_feed.php');[/insert_php]rm_news_feed.php:
<div class="vc_row wpb_row vc_row-fluid">
<div class="vc_col-sm-12 wpb_column vc_column_container ">
<div class="wpb_wrapper">
<div class="bg_parallax ">
<div class="">
<div class="vc_row wpb_row vc_inner vc_row-fluid">
<div class="inner-row clearfix">
<?php query_posts('cat=1&posts_per_page=3&orderby=desc'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php
if(has_post_thumbnail($post->ID)){
$thumbsrc = get_the_post_thumbnail($post->ID,'medium');
}else{
$thumbsrc = "<img src=\"images/no_featured_image.jpg\" alt=\"" . get_the_title() . "\">";
}
?>
<div class="vc_col-sm-4 wpb_column vc_column_container ">
<div class="wpb_wrapper">
<article class="ts-service-style3 ">
<a href="<?php the_permalink(); ?>"><figure><?php echo $thumbsrc; ?></figure></a>
<a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a><p><?php the_excerpt(); ?></p>
</article>
</div>
</div>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
</div>
</div>
</div>
</div>
</div>
</div>
我的问题是,当这个页面输出时,只要我使用the_excerpt(),它就会破坏主题,并显示一堆Visual Composer快捷码。如果我用静态文本替换the_excerpt(),它就能正常工作!但在我将其切换为the_excerpt()或the_content()的那一秒,所有的地狱都崩溃了。
我试过了:
$content = the_excerpt();
$content = preg_replace("/\[(.*?)\]/i", '', $content);
$content = strip_tags($content);这对删除短代码没有任何作用。
我能在这里做些什么?
发布于 2015-06-12 06:59:48
似乎与Insert-PHP和Visual Composer存在兼容性问题。
作为解决方案,我停用并删除了Insert-PHP插件,转而安装了Insert PHP Code Snippet plugin。
现在它工作得很好!
https://stackoverflow.com/questions/30790862
复制相似问题