Restrict results from the current author archive page
Custom code to display only results from the current author - when on the author archive page
add_action('asp_layout_in_form', 'asp_layout_in_form_author_archive_input', 10);
function asp_layout_in_form_author_archive_input() {
if ( is_author() ) {
?>
<input type="hidden" styl="display:none;" name="asp_author_archive" value="<?php echo get_queried_object_id(); ?>">
<?php
}
}
add_filter( 'asp_query_args', 'asp_archive_page_category_restriction', 10, 3 );
function asp_archive_page_category_restriction($args, $search_id, $options) {
if ( isset($options['asp_author_archive']) ) {
if ( !isset($args['post_user_filter']['include']) ) {
$args['post_user_filter']['include'] = array();
}
$args['post_user_filter']['include'] = array_unique(array_merge(
$args['post_user_filter']['include'],
array($options['asp_author_archive'])
));
}
return $args;
}
Copy link