admin管理员组

文章数量:1278918

I have a website with several custom fields, however when using the following code to search for a post, it only searches for the title or for the content, excluding the custom fields associated with the post or entry.

<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
  <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" placeholder="<?php esc_attr_e( 'Buscar por título, actor, año...', 'twentyeleven' ); ?>" />
  <input type="submit" class="submit" name="submit" id="boton" value="" />
</form>

any way to include custom fields in the search?

I have a website with several custom fields, however when using the following code to search for a post, it only searches for the title or for the content, excluding the custom fields associated with the post or entry.

<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
  <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" placeholder="<?php esc_attr_e( 'Buscar por título, actor, año...', 'twentyeleven' ); ?>" />
  <input type="submit" class="submit" name="submit" id="boton" value="" />
</form>

any way to include custom fields in the search?

Share Improve this question asked Oct 3, 2021 at 6:08 juanjuan 12 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

you can create your own search creating a file called search.php in your theme, there you can customize your search however you want.

probably you already have a way to call it, however you can call it with

get_search_form();

Tiago's answer will work if you wanna get coding. This plugin does exactly what you want in case you don't mind adding a new plugin to your install.

https://www.relevanssi

本文标签: phpInclude custom fields in search