简体   繁体   English

根据标题排除Wordpress中The Loop中的帖子

[英]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.

相关问题 当参数是数组时,排除WordPress循环中的帖子 - Excluding posts from WordPress loop when the argument is an array 从WordPress模板中排除类别名称(不包括帖子) - Excluding a Category Name (Not Posts) From A WordPress Template WordPress-“ The Loop”显示所有帖子,而不是发布首页标题 - WordPress - 'The Loop' to show all posts, instead posts the title of the home page WordPress侧边栏:使自定义循环显示与单个帖子相同类别的帖子,从列表中排除当前单个帖子 - WordPress sidebar: make custom loop display posts in same category as single post, EXCLUDING current single post from the list 有没有一种方法可以基于优先级在wordpress中显示帖子? - is there a way to display posts based on priority in the loop in wordpress? 从Wordpress中阅读的相关帖子中排除某些类别 - excluding certain categories from the read related posts in wordpress 将Wordpress帖子排除在相应类别之外 - Excluding Wordpress Posts From Being Displayed in Their Respective Category WordPress:如何发布不包括当前日期和所选日期的随机帖子 - Wordpress: How to make random posts excluding current and from chosen date 从Wordpress循环中排除某些帖子 - Excluding a certain post from Wordpress loop 如何在Wordpress中循环浏览自定义帖子并根据页面标题显示 - How to loop through custom posts in Wordpress and display according to page title
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM