You can use either the glsr_debug
or glsr_log
helper functions to help you figure this out. At the end of the code, add this to print the WP_Query object directly to the page:
glsr_debug( $query ); // or: apply_filters( 'glsr_debug', null, $query );
Alternatively, add this instead to print the WP_Query object to the plugin’s console (and if you have the Black Bar plugin installed, it will also show up in the Black Bar console…actually, this is only with Site Reviews v3.6.0):
glsr_log( $query ); // or: apply_filters( 'glsr_log', null, $query );
This will show you that the WP_Query object includes the following:
[meta_key] => pinned
[order] => DESC
[orderby] => meta_value date
Now that you know the existing values, simply change them to the ones you want. For example:
$query->set( 'meta_key', 'kodex_post_likes_count' );
$query->set( 'orderby', 'meta_value_num date' );