How To Limit Search Results For Specific Post Types in WordPress


How To Limit Search Results For Specific Post Types in WordPress
Becky Gardner

Hi,
I have a question and I couldn’t get a solution since last month.
I have lost of categories, pages and re-directions in my blog so my search box finds many unnecessary results when you try to search something. I want to customize my search.php for only categories part. In other words, we you search something, the results should be only from categories sections. So I will be get rid of redundant & duplicated results. My current codes are as below…Please help me

How to Limit Your WordPress Search Results
Shavon Peoples

So how do I go about creating a unique search form, that operates independently from the “whole site search form”, that is programmed to limit the results to posts of a single category? And I would like to do this in such a way that I don’t edit my theme files to achieve this, because I don’t want to have to redo this effort, every time there is an update to my theme. Is there a way that I can achieve this with a search form shortcode that is in some way customized to limit the search results to posts of a single category. Lastly, I don’t want to introduce a drop-down list of categories, because I don’t want my readers to have to choose the category. The category will be chosen for them by the nature of the page they are visiting. Thanks.

WordPress.org
Christena Inman

You’re going to have a rough time telling 2 search forms apart when they’re exactly the same. You can make them function differently depending what page the user is viewing but I thinking a better approach would be to make 2 separate searchform.php files.

How to Show Specific Post Types for Search Results in WordPress
Sue Rhodes

Although WordPress has a basic method to let users search your site, it doesn’t always provide the best results. If you can fine-tune the tool, it could improve engagement and on-page time of the site. And showing specific post types in search is a good way to accomplish this.

How To Limit WordPress Search Results to Custom Post Types
Inez Ross

This site is licensed under a Attribution-NonCommercial-ShareAlike 3.0 license. Feel free to change, reuse modify and extend it. Some authors will retain their copyright on certain articles. Haloseeker.com utilizes affiliate links and may receive a comission if you click an affiliate link and make a purchase.

WordPress.org
Gloria Russell

By default, WordPress provides a single configuration setting to control how many posts should be listed in each section of your blog. This value applies for the front page listing, author listings, archive listings, category listings, tag listings, custom post type listings, custom taxonomy listings, and search results. This plugin allows you to override that value for each of those different sections.

How to Use Multiple Search Forms In WordPress
Bryanna Atwell

So we will be assuming that you have two search forms, normal and books. This code is simply redirecting the search to the php file that handles that specific query. Now we just have to create those files. So, go ahead and create a normal-search.php and books-search.php file (just replace “normal” and “books” with whatever values you have been using).

Be the first to comment

Leave a Reply

Your email address will not be published.


*