[英]Excluding Posts from The Loop in Wordpress based on Title
I am trying to filter out some custom posts from The Loop that I have for my custom taxonomy query. 我试图从The Loop中过滤出一些自定义帖子,以用于自定义分类查询。
I have the code in a taxonomy-{custom-taxonomy-slug}.php file. 我在分类法-{custom-taxonomy-slug} .php文件中有代码。 Basically, I want any post that ends with the character "W" to be excluded.
基本上,我希望排除所有以字符“ W”结尾的帖子。
I'm trying to order these posts by title, but by default it is putting posts with the title ending in -W at the beginning. 我正在尝试按标题对这些帖子进行排序,但是默认情况下,它会将标题以-W结尾的帖子放在开头。 I want them at the end as the -W suffix is what we use to show that the post is not in our catalog.
我希望它们在最后,因为-W后缀是用来显示该帖子不在我们的目录中的内容。 So I was going to do that by just putting another loop at the end with the opposite rule.
因此,我将通过在相反规则的末尾放置另一个循环来做到这一点。
Anyway, here is what I am working with so far: 无论如何,这是到目前为止我正在使用的东西:
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; ?>
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; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.