Questions tagged [search]

The method by which users find information on your WordPress site

Filter by
Sorted by
Tagged with
6 votes
1 answer
7k 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 ...
user avatar
39 votes
6 answers
56k 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, ...
user avatar
  • 3,047
29 votes
1 answer
26k 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!
user avatar
13 votes
2 answers
59k 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 ...
user avatar
6 votes
2 answers
20k 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() { ...
user avatar
6 votes
2 answers
5k 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=...
user avatar
  • 152
51 votes
8 answers
217k 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?
user avatar
  • 527
45 votes
7 answers
35k 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 ...
user avatar
  • 1,086
32 votes
4 answers
70k 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 (...
user avatar
  • 623
3 votes
3 answers
3k views

Sticky posts on home page, search, tag and archives without plugin

I have a question today. I am looking for a solution to make sticky post available on my website. But, i just got it work on homepage with the code below. function wpb_latest_sticky() { /* Get all ...
user avatar
  • 703
21 votes
3 answers
24k 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 ...
user avatar
  • 1,622
15 votes
6 answers
35k views

How to search for (partial match) display names of WordPress users?

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 the ...
user avatar
  • 1,511
4 votes
2 answers
32k views

How do I search events between two set dates inside WP?

I am building a WP site with an events feature. The events page was made with custom post types. I want to make it possible for people to search/ filter events by dates. For example, they can search ...
user avatar
5 votes
1 answer
2k views

Extending search query with additional $sentence value

Next in my quest to extend WordPress is altering how WordPress uses the the $sentence variable in posts_search to include an additional string, when the $sentence variable meets a certain criteria. ...
user avatar
  • 1,883
2 votes
2 answers
7k views

filter search result with custom post type meta key

The default search returns all post types, which is what I want. But for one specific custom post type I want to limit the result to a specific meta key value (a custom date that must be greater than ...
user avatar
  • 163
23 votes
3 answers
9k 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 ...
user avatar
43 votes
2 answers
49k 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 ...
user avatar
  • 1,033
35 votes
13 answers
91k 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, ...
user avatar
  • 599
14 votes
6 answers
41k 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 ...
user avatar
6 votes
1 answer
2k 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)?
user avatar
  • 289
6 votes
3 answers
10k views

Wordpress Multiple Category Search

From few months I am digging into wordpress for multiple category search options, and finally came up with this. I just found that wordpress allows multiple tags, which means that if in your URL you ...
user avatar
3 votes
3 answers
8k views

Seperating Custom Post Search Results

I have a site that has a few custom post types. When a customer searches it shows a combination of all the different posts. I'd like to segment the two on the same page resulting in something that ...
user avatar
9 votes
1 answer
11k views

WP Query where title begins with a specific letter

I want to search for posts with WP_Query() and select only posts that begin with a specific letter. I found a bunch of old posts with filters that were pre-4.4, but since 4.4 there is a title search ...
user avatar
  • 113
0 votes
1 answer
2k views

How to redirect search result page to post

I'd like to redirect a search result page URL to a specific post. I've tried doing a 301 redirect in the .htaccess but it is not working. As an example: I want to redirect permanently the URL http:...
user avatar
19 votes
4 answers
20k views

How to highlight search terms without plugin

How can I get the search terms highlighted without plugin?
user avatar
  • 191
16 votes
8 answers
32k 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 ...
user avatar
  • 644
8 votes
7 answers
23k 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 ...
user avatar
4 votes
1 answer
22k views

Search that will look in custom field, post title and post content

I am looking for a way to perform a search, and while performing the search, it checks a custom field named 'keywords,' the post title, and the post content. If any of those fields have results like ...
user avatar
  • 51
8 votes
1 answer
13k 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 ...
user avatar
  • 261
7 votes
3 answers
10k 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 ...
user avatar
  • 101
2 votes
2 answers
4k views

How to get posts by content?

I found the following codes to get post details. However, it is not possible to get the posts by content. Does any one has any ideas? get_posts() //// get post //// $args = array( 'numberposts' ...
user avatar
1 vote
2 answers
12k views

Custom search for custom post type, custom meta and search fields

Id like to build a search form for a specific custom post type (vehicle) and have filters for that custom posts type's custom meta fields (price, age) and custom taxonomies (make). This will totally ...
user avatar
  • 129
1 vote
3 answers
3k views

Pagination broken when merging search results with additional WP_Query

On the search results page (search.php) I would like to perform an additional WP_Query to keep a specific order of search result types e.g. search results from authors should always be shown before ...
user avatar
  • 153
2 votes
1 answer
2k views

Search not working with title and content

I am working on search. I am able to search post by tag and category but not able to search by title and content. I tried below code but it's not working. Would you help me out? $getSearch = ...
user avatar
0 votes
1 answer
3k views

Custom search form with empty parameters

I'm building a custom search form with keywords and drop down lists (categories, date, and country (have a separate plugin for this)). In the searchform.php I have the input field and then select>...
user avatar
  • 373
0 votes
1 answer
2k views

Include images from pages in wp search.php results in default wp search

Is there a way to include page images in wp search? Like I want to search through my sites images on pages not in posts by caption/alt text and display them in the results page as thumbnails.
user avatar
  • 33
0 votes
1 answer
1k views

Search with filters and title

I would like to search in custom_post by title and by the ACF fields. So, I used the WP_Query WordPress function but I can't filter by the title, just by the filters. When I submit my form, I have ...
user avatar
  • 13
14 votes
5 answers
11k 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 ...
user avatar
11 votes
1 answer
6k 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 ...
user avatar
26 votes
3 answers
7k 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 ...
user avatar
18 votes
5 answers
18k 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
user avatar
11 votes
1 answer
5k 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 ...
user avatar
  • 445
11 votes
2 answers
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 ...
user avatar
  • 1,755
10 votes
3 answers
13k 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 ...
user avatar
4 votes
1 answer
3k views

The right way to create a custom search page for complex custom post types

I am trying to create a custom search page to show only custom posts types that meet specific search criteria. I have a complex form that involves different selects, radio buttons and text input ...
user avatar
  • 5,350
8 votes
2 answers
13k 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 ...
user avatar
6 votes
3 answers
4k views

Unique URL Every Time

I have created a small search tool that unless you know the EXACT code, you will not be taken to the post. For example, if I enter "OI812" it will take me to a custom post type that is ../CPT/OI812. ...
user avatar
  • 155
4 votes
1 answer
8k views

Filter results with custom field values and dropdown

I need to filter posts by a custom field value. My specific example: User browse to products > category 1 > subcategory A. ALL "subcategory A" items (products custom post type) are displayed as ...
user avatar
  • 585
4 votes
5 answers
4k views

How to replicate some of Drupal Views functionality in WordPress?

I admit, I still think in Drupal. (In choosing between developing in WordPress and Drupal, I still tend to favor Drupal, because I haven't yet figured out a few things on the WordPress side.) Can ...
user avatar
8 votes
5 answers
19k views

Empty search input returns all posts

So today I've decided to implement a search form onto my site that obviously returns a result when the user searches for it, but I've run into a little problem. My Problem When the user searches for ...
user avatar
  • 1,294