<?php
/**
* set author_name for a facetwp listing template query on a author archive page
* for compatibility with co-authors plus https://wordpress.org/plugins/co-authors-plus/
* change 'my_author_listing' in ln 9 to name of the facetwp listing you are using in the author archive
*/
add_filter( 'facetwp_query_args', function( $query_args, $class ) {
if ( 'my_author_listing' == $class->ajax_params['template'] ) { // change 'my_author_listing' to name of the listing you are using in the author archive
$query_args['author_name'] = !empty( get_query_var( 'author' ) )
? get_query_var( 'author' ) // on direct page load use query var
: array_pop( explode( "/", $class->ajax_params['http_params']['uri'] ) ); // on refresh get author_name from last part of FWP uri
}
return $query_args;
}, 10, 2 );