Restrict results from the current author archive page
Custom code to display only results from the current author - when on the author archive page
1
add_action('asp_layout_in_form', 'asp_layout_in_form_author_archive_input', 10);
2
function asp_layout_in_form_author_archive_input() {
3
if ( is_author() ) {
4
?>
5
<input type="hidden" styl="display:none;" name="asp_author_archive" value="<?php echo get_queried_object_id(); ?>">
6
<?php
7
}
8
}
9
10
11
add_filter( 'asp_query_args', 'asp_archive_page_category_restriction', 10, 3 );
12
function asp_archive_page_category_restriction($args, $search_id, $options) {
13
if ( isset($options['asp_author_archive']) ) {
14
if ( !isset($args['post_user_filter']['include']) ) {
15
$args['post_user_filter']['include'] = array();
16
}
17
$args['post_user_filter']['include'] = array_unique(array_merge(
18
$args['post_user_filter']['include'],
19
array($options['asp_author_archive'])
20
));
21
}
22
return $args;
23
}
Copied!
Last modified 28d ago
Copy link