这就是工作:http://localhost:8888/all-games?s=me
此操作无效(找不到页面):http://localhost:8888/all-games?s=met
职位名称:金属齿轮实心
以下是我的疑问:
$args = array("posts_per_page" => get_option("posts_per_page"), "post_type" => "astro_game", "paged" => get_query_var("paged"), "s" => $_GET["s"]);
$wp_query = new wp_query($args);
if ($wp_query -> have_posts()) :
/* Start the Loop */
while ($wp_query -> have_posts()) : $wp_query -> the_post();
get_template_part(\'template-parts/content-grid\', get_post_format());
endwhile;
else :
get_template_part(\'template-parts/content\', \'none\');
endif;
SO网友:Tunji
您应该使用get_query_var
而不是$_GET["s"]
, 这是一个内置的wordpress函数,用于检索public 已被解析并输入WP\\U查询的查询变量。
$args = array("posts_per_page" => get_option("posts_per_page"), "post_type" => "astro_game", "paged" => get_query_var("paged"), "s" => get_query_var("s");
Reference: WordPress_Query_Vars