我正在尝试从循环中过滤掉一些自定义帖子,这些帖子用于我的自定义分类查询。
我将代码放在一个分类法-{custom-taxonomy slug}.php文件中。基本上,我希望任何以字符"W“结尾的帖子都被排除在外。
我尝试按标题对这些帖子进行排序,但默认情况下,它会将标题以-W结尾的帖子放在开头。我想把它们放在最后,因为我们用-W后缀来表示帖子不在我们的目录中。所以我打算把另一个循环放在最后,用相反的规则。
不管怎样,到目前为止,我正在使用的是:
if ( have_posts() ) : ?>
<div id="blog-entries" class="clr <?php ks_blog_wrap_classes(); ?>">
<?php
while ( have_posts()) : the_post();
$title=substr(get_the_title(), -1, 1);
if ($title!=w) continue;
get_template_part( 'content-design-category', get_post_format() ); ?>
<?php endwhile; ?>发布于 2018-10-13 18:16:17
if ( have_posts() ) : ?>
<div id="blog-entries" class="clr <?php ks_blog_wrap_classes(); ?>">
<?php
while ( have_posts()) : the_post();
$title=substr(get_the_title(), -1, 1);
if ($title =='1') continue;
get_template_part( 'content-design-category', get_post_format() ); ?>
<?php endwhile; ?>https://stackoverflow.com/questions/31837721
复制相似问题