admin管理员组文章数量:1130349
I'm looking for a way to ensure a query always returns posts, even if the original query was empty. The query is a custom post type archive query, and my goal is to change a query var if the query has no results.
In the pre_get_posts filter, $query->have_posts() always returns no posts, so I can't find a way to do this – is there any way to predict whether a query will have results in the pre_get_posts filter?
I'm looking for a way to ensure a query always returns posts, even if the original query was empty. The query is a custom post type archive query, and my goal is to change a query var if the query has no results.
In the pre_get_posts filter, $query->have_posts() always returns no posts, so I can't find a way to do this – is there any way to predict whether a query will have results in the pre_get_posts filter?
本文标签: pre get postsModify a query with no results in pregetposts
版权声明:本文标题:pre get posts - Modify a query with no results in pre_get_posts 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749232681a2336756.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论