代码之家  ›  专栏  ›  技术社区  ›  UserEsp

搜索在具有特殊字符的wordpress中不起作用

  •  0
  • UserEsp  · 技术社区  · 8 年前

    我正在尝试搜索不同自定义字段的标题和内容。

    $args = array('exclude_from_search' => array( 'order-request'),
            "post_type" => array('post','document','page','event','product'),
            's' =>  get_search_query()
        );
    $context['posts'] = Timber::get_posts($args);
    

    但当我搜索类似的东西时 "Example ' Assistants" 即使这是一篇文章的标题,如果我搜索“示例”,文章也在那里。 我怎样才能包含一些特殊的角色?

    1 回复  |  直到 8 年前
        1
  •  0
  •   UserEsp    8 年前

    诀窍是将true中的默认转义值更改为false。 https://developer.wordpress.org/reference/functions/get_search_query/

    's' =>  get_search_query(false)
    
    推荐文章