• I was trying to run a query using
    relevanssi_do_query( $query );

    Complete code looks like this.

        $args = array(
          'post_type'      => 'product',
          'posts_per_page' => 1,
          'orderby'        => 'meta_value_num',
          'meta_key'       => '_price',
          'order'          => 'desc'
        );
    
        $query = new \WP_Query($args);
        $query->parse_query($args);
    
        relevanssi_do_query( $query );
    

    Error:

    Undefined index: meta_key in file C:\laragon\www\example\wp-content\plugins\relevanssi-premium\lib\sorting.php on line 157
    

    Version using: Relevanssi Premium [2.12.2]

    • This topic was modified 4 years, 2 months ago by Bhanu Singh.
Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi Premium support is here. However, since this question also applies to the free version, I am allowed to answer it here.

    The line 157 in sorting.php is

    $key = $wp_query->query_vars['meta_key'];

    It should be:

    $key = $wp_query->query_vars['meta_key'] ?? null;

    to cover cases where the meta_key index isn’t defined (it usually is an empty string, but looks like that’s not always true). I’ll fix that in the next version of Relevanssi.

Viewing 1 replies (of 1 total)
  • The topic ‘Undefined index: meta_key in file C:\laragon\www\example\wp-content\plugin’ is closed to new replies.