rank math fields for product not working

  • Bodav
    Participant
    2 years, 6 months ago #27848

    hello
    i am trying to sort the product by rankmath fields, i syncted them all as custom fields, tried both as text sortable and text not sortable but the query outputs all the products and i cant sort by keyword
    https://snipboard.io/PoVBEr.jpg

    also, in elementor, when i add new image (media is syncted with index), the images are shown there without any sort or date relevance..but in the wp admin they show fine

    wpsolr
    Keymaster
    2 years, 6 months ago #27851

    In the admin, you cannot sort by rankmath fields, only by standard WP fields (date, category, status).

    WPSOLR can replace media search in WP’s admin media library only.

    Bodav
    Participant
    2 years, 6 months ago #27852

    i see. so is it possible to achieve when trying to sort by rankmath, it will pull data from the database and not from elastic?

    wpsolr
    Keymaster
    2 years, 6 months ago #27853

    WPSOLR provides a hook to deactivate itself in admin search:

    add_action( WPSOLR_Events::WPSOLR_FILTER_IS_REPLACE_ADMIN_POST_TYPE_BY_WPSOLR_QUERY, [
    $this,
    'wpsolr_filter_is_replace_admin_post_type_by_wpsolr_query',
    ], 99, 1 );
    
    public function wpsolr_filter_is_replace_admin_post_type_by_wpsolr_query( $is_replace_by_wpsolr_query ) {
      $result = $is_replace_by_wpsolr_query && !( condition here on your url parameters or anything you want);
      return $result;
    }
    wpsolr
    Keymaster
    2 years, 6 months ago #27854

    You can inspire from wpsolr-pro/wpsolr/core/classes/extensions/premium/class-wpsolr-option-premium.php to eventually filter your own admin fields:

    add_action( WPSOLR_Events::WPSOLR_ACTION_SOLARIUM_QUERY, [$this,’wpsolr_action_query’,], 10, 1 );
    public function wpsolr_action_query( $parameters ) {

    }

    Bodav
    Participant
    2 years, 6 months ago #27855

    thanks.. too complicated for me i guess
    the above hook disables wpsolr totally on wp admin right?
    i dont want to do that for sure..it extremely improved my admin experience

    wpsolr
    Keymaster
    2 years, 6 months ago #27856

    You can use it to disable WPSOLR in admin only on your own conditions, like the presence of the RankMath fields in the sort query.

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

You must be logged in to reply to this topic.