Forums Forums Search & Filter Pro Search post ID's

Viewing 9 posts - 1 through 9 (of 9 total)
  • Anonymous
    #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?

    http://www.weathertex.com.au/gallery

    Trevor
    #85971

    Hi 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
    #86572

    Hi 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
    #86626

    I 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):

    https://wordpress.org/plugins/orbisius-child-theme-creator/

    Anonymous
    #86902

    I 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.

    Trevor
    #87000

    Most odd. The only other way I can think to do this is a bit laborious, but it would be to add a custom field to the posts and copy the post id into that, and then in Relevanssi you can get it to index the custom fields.

    Anonymous
    #88193

    I think adding a custom field to each post won’t be worth it.

    Maybe my settings in Relevanssi are incorrect?

    Trevor
    #88357

    I will have to ask Ross, the developer, for advice. I will get back to you.

    Ross Moderator
    #88684

    Hi 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

Viewing 9 posts - 1 through 9 (of 9 total)