Questions tagged [search]

The method by which users find information on your WordPress site

Filter by
Sorted by
Tagged with
44
votes
5answers
150k views

How to create a custom search for custom post type?

I have a search field for the blog posts, but I need an other for a custom post type. How can I create this custom search form with a different search result layout?
36
votes
2answers
40k views

Customizing Only a Specific Menu using the “wp_nav_menu_items” Hook?

Thanks to some help on here, I've managed to add a custom search box to my main menu... by adding this to my theme's functions.php add_filter('wp_nav_menu_items','search_box_function'); function ...
34
votes
6answers
24k views

Extending the search context in the admin list post screen

I have created a custom post type and have attached some custom fields to it. Now I would like to the search that authors can perform on the custom post list screen (in the admin backend) to also be ...
33
votes
6answers
44k views

Include custom taxonomy term in search

I have two custom taxonomies applied to two custom post types. the terms list on the sidebar just fine and will list all posts associated with it. However, if you search one of the terms in specific, ...
30
votes
4answers
65k views

Advanced search form with filters for custom taxonomies and custom fields

I'd like to build an advanced search form for a specific custom post type, having filters for the custom post types custom fields, custom taxonomies, and for a separate custom post types properties (...
27
votes
1answer
19k views

how to limit search to post titles?

Is there a way to limit search to post titles? I know I can modify query.php core file but there must be a way to do it with hooks right? Thanks in advance!
25
votes
9answers
57k views

Using meta query ('meta_query') with a search query ('s')

Trying to build a search that not only searches the defaults (title, content etc) but also a specific custom field. My current query: $args = array( 'post_type' => 'post', 's' => $query, ...
23
votes
3answers
5k views

Can I force WP_Query to return no results?

I'm working on a website with a search feature that allows users to search through a lot of post meta. There is a specific search pattern that I would like to forcibly return no results for. The ...
22
votes
3answers
8k views

How to create live autofill search?

I am currently trying to create a wordpress search function that shows live results underneath the search bar. There is an example on the World Bank website (screens below). I'm not looking for an ...
19
votes
3answers
19k views

How can I implement a location based (zip code) search in WordPress?

I am working on a local business directory site that will use custom post types for the business entries. One of the fields will be "Zip Code." How can I set up a location based search? I'd like ...
16
votes
1answer
31k views

Post_count only shows the number of results per page

I have a wp_query $wp_query = new WP_Query($args); but for some reason the $wp_query->post_count only shows the amount of posts on each page. So if I set 'showposts' => '10' and 12 results are ...
16
votes
8answers
27k views

Empty search returns home page, how to return not found search page?

The default search function if the search form is empty returns the home page, I want it to return a "sorry your search returned no results" page. this post doesn't answer it and this ticket tells ...
15
votes
3answers
16k views

How to highlight search terms without plugin

How can I get the search terms highlighted without plugin?
14
votes
5answers
9k views

How to search all user meta from users.php in the admin

The search form at the top of the users listing in the Admin area (wp-admin/users.php) is limited and does not search all of the user meta fields, such as bio, instant messenger handles, etc. I've not ...
13
votes
4answers
12k views

How do I remove Pages from search?

I don't need to search for pages in my site and only want to search posts, is there a way to do it? Thanks
12
votes
2answers
25k views

How can I search for a worpress user by display name or a part of it?

I need to create a search page that will display anything related to the supplied search. i.e. comments containing it, events, posts, CPTs and users with that name. How can I search for users in ...
11
votes
2answers
42k views

Creating a search form for custom fields

I have built a theme for a car dealership. Each car is a custom post type ("vehicle"), and has about 12 custom fields with things such as Make, Model, Mileage, Fuel Type etc. etc. So basically on the ...
11
votes
2answers
14k views

How does WordPress search work behind the scenes?

I am using WordPress search to search a range of custom post types and allow the user to drill-down into each individual post type. However I'm finding that WordPress is not returning what I'd deem ...
11
votes
2answers
2k views

How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?

I've been playing around with code snippets which add meta data to admin searches. The best snippet I've found was written by Stefano on this question. However, it appears to have 1, annoying bug ...
10
votes
1answer
4k views

Search posts by ID in admin

I'm looking for a way to search through posts by ID, preferably with support for custom post types. I was hoping there'd be a plugin enabling this functionality, but I've failed to find anything. Any ...
10
votes
1answer
5k views

Pretty permalinks for search results with extra query var

I'd like to know how I can rewrite a search URL that also contains an extra query var into a pretty permalink using wp_redirect and the template_redirect hook. I have taken the code from the Nice ...
9
votes
4answers
1k views

Limit search to latin characters

I'd like to limit search to characters used on the English language + numbers. The reason is that looking at the slowest queries on mysql log i found most come from searches in Arab, Russian and ...
9
votes
2answers
7k views

Extend WordPress search to include user search

There is many a WordPress plugin out there that enhances WordPress search but I have yet to find a plugin that will add user search. Search Everything used to have the functionality but was removed ...
8
votes
6answers
26k views

How to make search include data from wp_postmeta?

I have a site using Advanced Custom Fields to create and store various bits of relevant info. These need to be included in the main general search, which by default only searches the title and main ...
8
votes
2answers
5k views

Remove some pages from search

On my site, I want some pages to not be queriable by the search form (so they don't appear when I've got something like www.ex.com/?s=banana) Is there a way to "Remove" pages from the search results ...
8
votes
1answer
782 views

How to look at code in WordPress repositories without downloading?

A lot of questions are about plugins and themes, that you don't necessarily have installed. Downloading zip archive, unpacking and opening in editor seems like a too much hassle. If only there was a ...
8
votes
2answers
10k views

AJAX search on post pages by custom post type

I'm having an issue creating an ajax search on my single post pages. I need to limit the search results to the custom post types "fod_videos" and "post" and category 12. My issue is the search is ...
8
votes
2answers
3k views

How can I create a taxonomy meta-box with search suggestions but no new terms input?

I was wondering how I could setup a taxonomy metabox on a post edit page that would be similar to the "tags" kind (with search field and automatic suggestions), but without the right to add a new term....
7
votes
3answers
69k views

How to remove search bar from a wordpress theme? [closed]

How to remove search bar from a wordpress theme?
7
votes
1answer
8k views

group search results by post type?

My site has 3 unique post types: Default Blog posts ("post") custom type "lesson" custom type "series" When the user searches the site, I would like pertinent results from all 3 post types to show ...
7
votes
1answer
836 views

How to redirect to post if search results only returns one post

I want to send visitors to my search.php after a search to display list of posts. If there is only one search result, user can directlyto the post in question(something like GOOGLE's I am Feeling ...
7
votes
1answer
26k views

How do I add a search bar to my header?

I need to add a functioning search bar to my header. I have read through the forums but am unsure what code I need to put where. For instance, where do I put the css code versus where do I put the ...
7
votes
2answers
20k views

Display search results within the same page

Problem I have a page on my site where I need to do additional searching within that page. I am using the default way of WordPress searching with <?php get_search_form(); ?> for my main header ...
7
votes
1answer
7k views

Possible to search by author name with default WordPress search function?

I realize improving WordPress's search function is a huge can of worms, but the ONLY additional thing I need it to do is to show results when I search for an author's name. For example, if we have an ...
7
votes
3answers
21k views

How to make a WP_Query search with custom post types?

I've registered a custom post type called "node". When I create a basic WP_Query to get posts of that type, it works just fine. Example: $args = array( 'post_status' => 'publish', 'post_type' =&...
7
votes
1answer
491 views

WordPress blog with 30 000 posts: poor search performance

Our WordPress blog was running just fine until we imported about 30k posts. The search on the website became very slow after that. It now takes about: - 4 seconds to load a page with Search & ...
7
votes
1answer
294 views

Development of a Wordpress Search Plugin - Best Practices

Searching for around two days to find an answer to my question, I finally registered for this StackExchange. :) My Question is not simple, so I need to start at the very beginning. But to give you an ...
6
votes
3answers
9k views

Searching multiple custom post types and pages

I'm using bainternet's method for searching custom post_types and it works great. However, I've recently been requested to return more than one "specific" post type and perhaps individual pages for a ...
6
votes
2answers
3k views

Custom search filter causes menu and query_posts problems

I'm using a custom search filter (using my custom query var type), like so: function fteh_pre_get_posts( $query ){ if( isset( $query->query_vars['type'] ) ) $types = explode( ',', $...
6
votes
1answer
6k views

Template issues getting ajax search results

I'm trying to put search results into a div with ajax. The issue is I'm getting errors saying undefined function have_posts() when the the search template is accessed. It also took issue with ...
6
votes
2answers
4k views

Exclude Specific Term from Search

It is possible to search for posts with a specific term by appending the URL with: ?&term=abc Is it possible to do the opposite and search excluding a specific term? Something like: ?&term=...
6
votes
1answer
1k views

Insert DIV container below 1st search result

How can I insert a DIV just below the first search result (between result #1 and #2)?
6
votes
2answers
16k views

paginate_links() don't properly work in search.php?

I'm using this in my search.php template … <div class="pagination"> <?php echo get_pagination_links(); ?> </div> And this is the function … function get_pagination_links() { ...
6
votes
2answers
2k views

How can I change the admin search posts fields?

I have a custom post type that includes many custom fields. I would like to add them as a search target to admin search. Currently the admin search searches only the content and the title, I would ...
6
votes
1answer
308 views

A search for '0' returns results

I have a a CPT set up with a custom taxonomy attached to it. I recently noticed that if I search for 0 (zero), in the back-end as well as the front-end, it gives me results. None of these resultant ...
6
votes
5answers
12k views

Including categories in search results

I am trying to include categories in search results. I've been searching for hours now with no solution. By "including categories" I don't mean search in a certain category, I mean let's say I have a ...
6
votes
1answer
2k views

How to make Wordpress search prioritise page titles?

The standard search for Wordpress works, but doesn't seem too clever. If I search for 'tomato' and I have a page whose title is 'Tomato' I would expect that to come first in the results. However the ...
6
votes
2answers
16k views

Including custom fields in search?

I use custom fields for lots of my content on both Posts and Pages, so that half of the text will be in the main post body and the other half in a custom field. Unfortunately, when doing this only ...
6
votes
2answers
9k views

How to correctly submit a search form and display the result in an independent page

I have part search function in my WordPress website which uses dynamic dependent select box. However, now I have the following problem: If only select the first one box, or select the first two ...
6
votes
1answer
1k views

Search Custom Post Type Pages and Custom Fields in 2 Dropdowns?

On my custom post type pages I have custom fields that the user can edit. What I want is to have a search form with 2 select dropdowns: one dropdown that is populated with all the top-level custom ...