Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress-如何仅搜索页面_Wordpress_Search - Fatal编程技术网

Wordpress-如何仅搜索页面

Wordpress-如何仅搜索页面,wordpress,search,Wordpress,Search,我需要一些Wordpress搜索方面的帮助。我想知道的是如何只搜索Wordpress页面。你可能想在Wordpress论坛上查看这个。 您必须在搜索表单中添加一个隐藏表单字段,并添加一个钩子来更新wordpress生成的查询 编辑:这是上面提到的论坛帖子的代码 在搜索表格中: <input type="hidden" name="post_type" value="page" /> 你可能想在wordpress论坛上看看这个。 您必须在搜索表单中添加一个隐藏表单字段,并添加一个钩子

我需要一些Wordpress搜索方面的帮助。我想知道的是如何只搜索Wordpress页面。

你可能想在Wordpress论坛上查看这个。 您必须在搜索表单中添加一个隐藏表单字段,并添加一个钩子来更新wordpress生成的查询

编辑:这是上面提到的论坛帖子的代码

在搜索表格中:

<input type="hidden" name="post_type" value="page" />

你可能想在wordpress论坛上看看这个。 您必须在搜索表单中添加一个隐藏表单字段,并添加一个钩子来更新wordpress生成的查询

编辑:这是上面提到的论坛帖子的代码

在搜索表格中:

<input type="hidden" name="post_type" value="page" />

在您的search.php中,找到循环并在其后面插入此代码。您可以识别循环,因为它通常以以下内容开始:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
因此,您的代码应该如下所示:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
<?php if (is_search() && ($post->post_type=='post')) continue; ?>

让我知道它是否有效。

在您的search.php中,找到循环并在其后面插入此代码。您可以识别循环,因为它通常以以下内容开始:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
因此,您的代码应该如下所示:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
<?php if (is_search() && ($post->post_type=='post')) continue; ?>
让我知道它是否有效