WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
Relevanssi, WPML and translated custom posts/taxonomies (6 posts)

  1. Rics1983
    Member
    Posted 1 year ago #

    Hi, i've installed both WPML and Reevanssi plugin.
    I have a custom post type and five custom taxonomies, all translated in 5 different languages.
    I would to know if is possible to search, with the wordpress searchform, for a post with a keyword in a language and get in the results not only the found post for the matching language keyword, but also the translations versions of that post found by the keyword.

    Thanks!

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Not out of the box, but I suppose writing a filter function on the relevanssi_hits_filter hook that would process the hits found and add the translated versions would not be particularly complicated.

  3. Rics1983
    Member
    Posted 1 year ago #

    Thank you for the advice Mikko, i will check that filter.
    I'm merging the functionality of three plugins:
    WPML, Relevanssi and Query Multiple Taxonomies to achieve a particular search system.
    I'll update this thread as soon i've news on this "challenge".

  4. Rics1983
    Member
    Posted 1 year ago #

    Hi haven't had yet the time to try the relevansi_hits_filter, but in the meantime i've tought about another question:

    Is possible to get the terms (not filtering the results with terms) and place them in a variable that then i can send to another plugin (In my case Query multiple taxonomies = QMT)?

    At the moment, on search.php page, inside the loop, i've placed some variables defined with

    $term_list_taxonomy1 = wp_get_post_terms($post->ID, 'taxonomy1', array("fields" => "all"));
    $term_list_taxonomy2 = wp_get_post_terms($post->ID, 'taxonomy2', array("fields" => "all"));
    //And so on..

    and then getting the slug terms with

    $term_list_taxonomy1[0]->slug
    $term_list_taxonomy1[1]->slug
    $term_list_taxonomy2[0]->slug
    $term_list_taxonomy3[0]->slug

    In this way i can build a query string suitable for QMT:
    ?taxonomy1=term+term&taxonomy2=term&taxonomy3=term

    I successfully obtained the QMT suitable string, that placed in an html anchor tag will work when clicked, it updates the QMT lists in the sidebar.

    What i need now is to send this string, as variable, to the QMT plugin before QMT starts.
    As it is now, i can create the variable $qmt_string containing the complete string, but it is created inside the search.php template page loop.
    Instead, i have to create it before QMT fires, as it will be required from QMT when a search is performed.

    The flow is the following:

    -I put a keyword into the searchform.
    -I click the search button.
    -In this moment i do both the search and the $qmt_string variable creation placing into it the QMT suitable string.
    -The $qmt_string variable will be filled and ready to be read from the QMT plugin.
    -Search.php template wiull show the search results and the QMT lists on the sidebar updated with the string that i sent to QMT, $qmt_string.

    What i've noticed is that anything i put at the start of the functions.php will be processed before QMT.
    So, i assume that if i can make use of some relevanssi function inside the functions.php, that can create the $qmt_string before it's loaded QMT, and before the results are displayed on the search.php template, i could achieve my goal.

    But i don't know if this is possible using relevanssi Outside of search pages or using the relevansi_do_query function.
    Or using another different solution...don't know..

  5. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Check out the action hooks WordPress processes before showing the page. Relevanssi runs on 'the_posts' hook, so if you need to do something before Relevanssi is triggered, you must do it before 'the_posts' is done.

    So, create the string as early in the flow as possible. See this: http://codex.wordpress.org/Plugin_API/Action_Reference

  6. Rics1983
    Member
    Posted 1 year ago #

    Well, i need Relevanssi to be triggered as i need the results to build the string.
    The string is builded on the Relevanssi results, that can vary everytime by the different keyword typed on the searchform.
    Considered that i have a page with the searchform on the main content and the QMT list (filled by the QMT functionality) on the sidebar, the timeline steps should be:

    1-Write the keyword on the searchform.
    2-Click on the search button
    3-Get the Relevanssi results, and use these results to build the string that will be assigned to a variable that will be sent to QMT.
    4-QMT will read the string variable.
    5-Show the Relevanssi results (from 1st & 2nd steps) on the search.php page and show the lists of QMT on that page sidebar (list updated using the string variable generated on step 3), both in the same time.

    That's why i think i can't fire my string build before relevanssi, as i need relevanssi results to build correctly the string that will then feed the QMT plugin. Only after this i will show the results and the updated QMT list.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic