WordPress triggers 404 on page 2 for custom search query

index.php is the default template, the fallback. If we look here: http://codex.wordpress.org/Template_Hierarchy And at the diagram: We can see here that search.php is the appropriate template. Have you considered using author.php and the author archives instead of modifying the search template? There are far better ways of implementing what you want, even the searching via … Read more

Show matching categories in search page

Essentially what you need is show the categories the current queried posts belong. I’ll post here a function that take as argument a taaxonomy (or an array of taxonomies) and return all the terms in that (those) taxonomy(ies) that are assigned to all queried posts. function queried_posts_terms( $taxonomies=”category” ) { global $wp_query, $wpdb; if ( … Read more

Get Adjacent post by search query

I’m not entirely sure, but it seems like you want to store the last visited page for future use (a go back button?). I see two ways to do this: Keep it in the URL as a get argument the same way you save the search queries. This leads to a long url, though Save … Read more

Restrict WordPress Search to Custom Field

On WordPress you can filter searches when accessing the URL with an additional parameter on the end for example; https://www.your-website.com/?s=search-query&post_type=custom_post_type_name If you are accessing this URL from a search box / form on your website, add in the following hidden field; <input type=”hidden” name=”post_type” value=”post type name” />

How to display search results in search.php

get_search_query() returns only the string that the user searched for. To display the search results, you’ll need to do some more work. The search results will be in $wp_query, and you can manipulate it using The Loop (like any other page). The following code is adapted from WordPress’s own Twenty Twenty theme‘s index.php file, and … Read more

Can anyone offer any help with this function?

The filter you are using posts_where affects the creation of SQL query, so by definition it is executed before query runs and you have any search results. So you cannot loop through results at this point, what you can do is retrieve or hardcode list of unwanted items from elsewhere and use them to modify … Read more

Include custom taxonomy term in search

I would recommend the Search Everything plugin too, but if you want to implement this using WP’s search function, here’s the code I’m using in my Atom theme: // search all taxonomies, based on: http://projects.jesseheap.com/all-projects/wordpress-plugin-tag-search-in-wordpress-23 function atom_search_where($where){ global $wpdb; if (is_search()) $where .= “OR (t.name LIKE ‘%”.get_search_query().”%’ AND {$wpdb->posts}.post_status=”publish”)”; return $where; } function atom_search_join($join){ global … Read more

Passing form inputs into multi-taxonomy query

You mention that with your first attempt you get the URL http://sitename.com/?brand=22 which is correct as you’ve used a get method, but you don’t say what code you’re using for the query. Personally I use this for my form and would agree with wdalhaj to use post instead of get <form id=”brandsearch” method=”post” action=””> <select … Read more