How do I exclude a specific page (and child pages) from the search results?

// Filter to exclude a page and it’s child pages from search query function myfilter_exclude_pages_from_search( $query ) { // Save the post id of the page to be excluded in $parent_post_id_to_exclude $parent_post_id_to_exclude = 111; // Replace 111 with actual page id // Convert the post id to an array $parent_post_id_arr = array( $parent_post_id_to_exclude ); // … Read more

Changing the ORDER BY in WordPress default search function

If I were you, I would likely use the posts_search_orderby hook to change the search ORDER BY clause, because that way, the sorting would work with pagination. So for example in your case, you would want to sort by the post type like so: (well, if the “product posts” is of a different post type?) … Read more

Changing default wp search string

By default WordPress use a + between spaces No, it doesn’t. WordPress doesn’t generate + characters, it doesn’t use those characters, and it can’t see them. So Where Does the + Come From? The browser and URLs. Spaces in URL parameters are encoded as + characters or %20. Forms specifically become +. When data that … Read more

Custom search Dashboard widget

Firstly, let’s start off by cleaning up the query you have above. I’ve put it into Heredoc syntax to make it easier to read. $sql = <<<SQL SELECT * FROM {$tablename} — you should use interpolation when working in a string that can have variables WHERE ( — Your query will only ever match one … Read more

Should I create a parent page with no content? [closed]

Your question is a bit out of the scope of this site, but according to Google, creating any URL without content would not be beneficial for SEO. It would likely work better SEO-wise to create a custom post type that has no archive, so you have the parent slug you’re wanting in the URL without … Read more

Search function does not work on mobile devices

In WordPress the name for a search field must be s. WordPress automatically performs a search on any request where s is present. For some reason your theme has a separate search field named m that is displayed on mobile. This won’t do anything unless custom code is added to handle this. But that’s not … Read more

Include results with tags relevant to the search keyword with JSON rest API v2

WP Extended Search does not work with REST by default since version 2.0.2 This is to achieve maximum compatibility with WordPress and other plugin/themes. To enable the support, pass wpessid in REST request with ID (for specific search setting) or without ID (for global search setting). e.g. /wp-json/wp/v2/posts?search=technology&wpessid or /wp-json/wp/v2/posts?search=technology&wpessid=10 Ref: https://wordpress.org/support/topic/search-queries-with-metakey-name-issue-version-2-0-2/#post-14376988 PS:- I am … Read more