Forums › Forums › Search & Filter Pro › Search post ID's
- This topic has 8 replies, 3 voices, and was last updated 7 years, 11 months ago by Ross.
-
Anonymous(Private) January 27, 2017 at 2:47 am #85966
Hi,
I am using your plugin to display a media gallery.
I would like to search the post ID? I have added a search type input along with my other filters but for some reason does not search the post ID number that I now have displayed under each photo?
Trevor(Private) January 27, 2017 at 7:19 am #85971Hi Chris, you need to take 3 steps, I think:
#1 Install the free relevanssi plugin (you might need to enable the indexing of excerpts for this to work properly, I don’t know why?).
#2 Edit the child theme functions.php file and add this code:add_filter('relevanssi_content_to_index', 'rlv_index_post_id', 10, 2); function rlv_index_post_id($content, $post) { $content .= " " . $post->ID; return $content; }
[If you are not using a child theme, you should. It is easy to make one. If you are unsure, and your theme doesn’t have a child theme making function, you can use the https://wordpress.org/plugins/orbisius-child-theme-creator/ plugin.]
#3 In the Form settings, under the Advanced tab, enable to Relevanssi support (you probably won’t need the relevancy setting though).
Then, any number you enter in the search box should be searchable.
Anonymous(Private) January 29, 2017 at 10:59 pm #86572Hi Trevor,
I think I followed these steps right but search post ID still wont work.
Infact when the relevanssi plugin is activated, it breaks the search bar if you search a name of a product etc.
I am unsure if I enabled the indexing of excerpts properly?
Also I am not using a child theme at the moment but I did copy that code into the functions file, this issue would not cause it to not work would it?
Trevor(Private) January 30, 2017 at 9:59 am #86626I do not know if not using a child theme would cause this. Without this code, is everything working (apart from the POST ID search)?
FWIW, working without a child theme is not a recommended way to work. It is generally ‘a good thing’ to always have a child theme. They are easy to make. There is a good plugin you can use to do it (you can remove the plugin after you are done making it):
Anonymous(Private) January 30, 2017 at 11:20 pm #86902I created a child theme and still same issue.
The code you asked me to add to the functions doesnt effect either. When the relevanssi plugin isnt activated. The search works fine. When the relevanssi plugin is activated is when no results are found at all.
Ross Moderator(Private) February 7, 2017 at 10:58 pm #88684Hi Chris
When we power our searches with Relevanssi, we simply pass over the query to Relevanssi to add their search engine to our results.
To get what you want working, which is, Relevanssi searching for Post IDs, is really a Relevanssi question and not something we can give full support to here (we’re not the devs, but we do try).
What Trevor suggested sounds right to me but I haven’t tested the code.
To get what you want working I would simplify the approach in to 2 steps:
1) First, get Relevanssi working so that it searches Post IDs (I’ve just found the same code snippet on their website Trevor posted: https://www.relevanssi.com/knowledge-base/searching-post-id/)
Test this with your default WP search (do not try anything with S&F yet) – Relevanssi by default works on WP search pages (ie
yoursite.com/?s=searchterm
). Does it successfully search Post IDs? If it doesn’t, I’m afraid there is an issue with your setup & relevanssi – so you will have to open a ticket with them)2) Once you know that is working, test Relevanssi with S&F and see if this is working also. If not, then let us know and we can look into it further.
Best
-
AuthorPosts