You need to find posts, the title and / or content of which contains the exact phrase consisting of two or more words. I tried this:

$args = array ( 'posts_per_page' => -1, 'post_type' => 'post', 's' => 'множество чудес', 'exact' => true ); $posts = get_posts($args); 

So does not find anything. Without the parameter, 'exact' finds, but at the same time, it does not find much needed (it finds the words 'set' and 'wonders' in different places of content, which is not good).

  • Where to find? Who is looking? User on the site or what is the purpose of the search? - SeVlad
  • Find among all the posts. On the page you need to display posts containing the phrase - Valentin Dranyy
  • Those. user on the site. Check it in question .. - SeVlad
  • I have an arbitrary post field, it contains a phrase (keyword). And on the basis of this phrase, I need to display posts that have this phrase in the content or title. - Valentin Dranyy

1 answer 1

Search in quotes will solve the problem.

  • Specify, I need to get this task through get_post or WP_Query - Valentin Dranyy
  • thanks solved this problem. Tell me where you can read about these ext. characters? - Valentin Dranyy
  • What kind of extras? Quotes simply tell the search script that this is one search string. - SeVlad
  • and what else can you substitute. For example, if you put a minus before a word, then this word will be excluded. I would like to have a complete picture. - Valentin Dranyy
  • This kind of is not in the core. But once met plugins advanced search. - SeVlad