• Resolved walpap

    (@walpap)


    Mikko
    Im using a plugin called Edit Flow.
    It can create new custom statuses for all post types in the backend.
    So i created one custom status in the products post type called “sold”
    So everytime a product is sold, it takes that status.
    This means i have all this statuses: All, published, draft, pending, and “sold”.

    My problem is that a product that is being searched ok with relevanssi in the ALL view, after changing its status to sold, then it does not being found by relevanssi anymore. It disappears from the search.

    I want to add, that relevanssi actually “see” the custom status in the taxonomies list as: post_status but indexing it, doesnt make any change. I also tried adding the sold word to the custom field list, but it didnt work also.

    Is it possible to fix this?
    Thank you!

    https://wordpress.org/plugins/relevanssi/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Yes, you can fix this. By default, Relevanssi only indexes the following post statuses: publish, private, draft, pending, and future.

    If you want to add a status to that list, you need to add this to your theme functions.php:

    add_filter('relevanssi_valid_status', 'rlv_add_status');
    function rlv_add_status($status_array) {
        $status_array[] = "sold";
        return $status_array;
    }

    Then reindex.

    Thread Starter walpap

    (@walpap)

    Mikko, you are awesome! You give a great support even to free users.
    Thank you so much. Really.

    I forgot to mention that the “sold” products are with 0 stock, so they dont appear in the front end. I just want to search them in the admin section.

    So.. the code you sent me didnt work at first..
    I added it to the functions.php of my theme, then reindexed relevanssi.
    I realized the number of indexed posts grew up, so it did something..

    But then i wanted to search one product with the “sold” status, and it still didnt found it. I think you missed something there.

    So i went to Relevanssi plugin files, and found this line in common.php

    // only show drafts, pending and future posts in admin search
    	if (in_array($status, array('draft', 'pending', 'future')) && is_admin()) {
    		$post_ok = true;
    	}

    So i added ‘sold’ after future, and then it worked.

    Im happy with that, but i would like not to touch the plugin files.
    So i ask you if what i did was ok and if you can correct the code you wrote before, so i can use only functions.php.

    Take care!

    Plugin Author Mikko Saari

    (@msaari)

    Hmm, that is hardcoded, and cannot be changed by a filter. Let’s add a filter there, then. Change the code to this:

    // only show drafts, pending and future posts in admin search
    	if (in_array($status, apply_filters('relevanssi_valid_admin_status', array('draft', 'pending', 'future'))) && is_admin()) {
    		$post_ok = true;
    	}

    Then add this to your theme functions.php:

    add_filter('relevanssi_valid_admin_status', 'rlv_add_status');

    Now it should work and be update proof as well, I’ll include the filter in the next version.

    Thread Starter walpap

    (@walpap)

    Mikko, when you say:

    “Then add this to your theme functions.php:
    add_filter(‘relevanssi_valid_admin_status’, ‘rlv_add_status’);”

    You mean to add it like this, right?

    add_filter('relevanssi_valid_admin_status', 'rlv_add_status');"
    function rlv_add_status($status_array) {
        $status_array[] = "sold";
        return $status_array;
    }

    Because, if i dont add the function after, it does not work.

    Plugin Author Mikko Saari

    (@msaari)

    I assumed you had the function already, because you need the other filter hook as well, like this:

    add_filter('relevanssi_valid_status', 'rlv_add_status');
    add_filter('relevanssi_valid_admin_status', 'rlv_add_status');
    function rlv_add_status($status_array) {
        $status_array[] = "sold";
        return $status_array;
    }
    Thread Starter walpap

    (@walpap)

    Thank you very much Mikko!
    Take care.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Edit Flow plugin custom statuses not show in the results’ is closed to new replies.