阅读Wordpress文档后,我意识到您可以使用"The Loop"中的过滤器从索引中删除帖子,例如:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- The following tests if the current post is in category 3. -->
<?php if (in_category('3')) continue; ?>
<!-- display normal post -->
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)
我想知道的是,如果有过滤器/钩子来过滤帖子have_posts()而不修改模板.到目前为止,我找到了更改结果的选项,但没有从结果集中删除结果.
因此,您想将其从显示中删除,但仍将其保留在“那里”,以防您决定稍后显示它?不太清楚你想做什么。
举一个例子,过去我使用查询帖子来将类别保留在我的主页之外:http://codex.wordpress.org/Template_Tags/query_posts#Exclude_Categories_From_Your_Home_Page
| 归档时间: |
|
| 查看次数: |
7993 次 |
| 最近记录: |