【问题标题】:Remove the_content From Wordpress Loop从 Wordpress 循环中删除 the_content
【发布时间】:2013-03-03 03:39:45
【问题描述】:

我试图弄清楚如何在 wordpress 循环中显示仅包含某些元素的自定义循环。

我的循环当前包含标题、创建日期、作者和内容。

但是,我正在尝试删除循环中每个帖子的内容,因为我不希望它在没有运气的情况下显示在此列表中。我什至已将 the_content() 从循环中删除,它仍然会在循环部分下显示帖子内容的列表。

任何帮助将不胜感激,

这是我的代码:

<?php query_posts('category_name=halloween &posts_per_page=6'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- IF articles then display them -->

<h6><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h6>   
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>

<?php endwhile; else: ?>
<!-- IF no articles were created then show -->

NO Posts Present 

<?php endif; ?>

【问题讨论】:

标签: php wordpress


【解决方案1】:

我似乎找到了我的代码中缺少的内容,因为在我的循环结束时需要以下 sn-p 代码来解决问题:

这是我在 endif 之后添加的代码

<?php wp_reset_query(); ?>

【讨论】:

    猜你喜欢
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    • 2013-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-12
    • 2016-03-04
    相关资源
    最近更新 更多