https://github.com/emmannweb/custom-search-for-all-custom-post-type
custom search in wordpress to display all the post type in search result
https://github.com/emmannweb/custom-search-for-all-custom-post-type
wordpress-development
Last synced: 3 months ago
JSON representation
custom search in wordpress to display all the post type in search result
- Host: GitHub
- URL: https://github.com/emmannweb/custom-search-for-all-custom-post-type
- Owner: emmannweb
- Created: 2019-01-17T03:29:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-25T16:40:41.000Z (over 6 years ago)
- Last Synced: 2025-10-30T06:42:19.791Z (9 months ago)
- Topics: wordpress-development
- Language: PHP
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# custom search in wordpress for adding all our custom post type.
### to begin ...
we need to add those parameters in the search form:
in the input name="s" and action =`````` method="GET"
### After those setup up...
just add in your theme functions file the code provided...
### Explanation
the "pre_get_posts" hook will modify the normal query of wordpress, so that we can put ours.
we added condition to check if it's the search query (remember we passed in the name of the input field name="s").
after that we set the query for post type that allow us to choose which custom post type we wanna make appear
in the search result.
The post per page is set to 3, so you can add a custom pagination to display your posts; or set post per page -1 to display all post.
#### that's it!