我在主页上有两个不同的WP查询。我需要检查函数中的$home\\u查询条件。php然后,如果$home\\u query返回null,我想做些什么。我尝试了pre\\u get\\u posts操作,但我无法捕获$home\\u查询数据,而且它运行了两次,因为页面上有两个WP\\u查询。
使用If$home\\u query返回null的分页方式,我想将页面重定向到404页面并获取404响应的代码。
例如https://example.com/page/200/ 页码是200,但在页面中没有200页码,我想重定向404页面并得到404响应,而不是;“不显示结果文本”;
指数php
$home_query = new WP_Query( array(\'posts_per_page\' => get_query_var(\'posts_per_page\'),\'paged\' => $current_page ) );
$featured_post = new WP_Query(array(\'p\'=>get_theme_mod(\'featured-content-callout-post\'),\'order\' => \'DESC\',\'posts_per_page\'=> 1));
if($home_query->have_posts()):
while ($home_query->have_posts()):
$home_query->the_post();
get_template_part(\'template-parts/content\',\'list\');
endwhile;
else;
// get_template_part(\'template-parts/content\',\'none\');
// I tried to use redirect code in here but I couldn\'t.
endif;
谢谢你的帮助