• Resolved gavin310

    (@gavin310)


    Relevanssi works as-is with the post ordering plugin I’m using (Real Custom Post Order) but the results are out of order. So I add the following filter as per the docs:

    add_filter( 'relevanssi_orderby', function( $orderby ) {
    	$orderby = 'relevance';
    	return $orderby;
    } );

    This fixes the post order, but at the top of the page it outputs:

    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386
    Warning: Undefined array key -1 in /Users/me/Local Sites/sitename/app/public/wp-content/plugins/relevanssi/lib/sorting.php on line 386

    If I remove the filter the warnings go away, and if I disable Real Custom Post Order the warnings goes away. I know the issue may be with the post ordering plugin, but I’m wondering if you have any advice here. Thanks!

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

    (@msaari)

    Try using this:

    add_filter( 'relevanssi_orderby', function( $orderby ) {
    	$orderby = array( 'relevance' => 'desc' );
    	return $orderby;
    } );

    Looks like the sorting direction may be missing.

    Thread Starter gavin310

    (@gavin310)

    Man, you are awesome. That fixed it. THANK YOU!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘“Undefined array key” when using relevanssi_orderby filter w post order plugin’ is closed to new replies.