This is just an example and you should modify it the way you want, we will be using a custom query and rewrite rule to build the url
First thing you need to do is to create rewrite rule for the two custom query you want to display.
example, you have to reset the permalink in order for the new rewrite rule to take effect,
this is better to be created in a class and in a custom plugin so you can simply call flush_rewrite_rules() function
during plugin activation to reset the permalink.
function _custom_rewrite() {
// we are telling wordpress that if somebody access yoursite.com/all-post/user/username
// wordpress will do a request on this query var yoursite.com/index.php?query_type=all_post&uname=username
add_rewrite_rule( "^all-post/user/?(.+)/?$", 'index.php?query_type=all_post&uname=$matches[1]', "top");
}
function _custom_query( $vars ) {
// we will register the two custom query var on wordpress rewrite rule
$vars[] = 'query_type';
$vars[] = 'uname';
return $vars;
}
// Then add those two functions on thier appropriate hook and filter
add_action( 'init', '_custom_rewrite' );
add_filter( 'query_vars', '_custom_query' );
Now that you have build a custom URL you can then load a custom query on that custom url by creating a custom .php file as template and using template_include filter to load the template if the url/request contains query_type=all_post
function _template_loader($template){
// get the custom query var we registered
$query_var = get_query_var('query_type');
// load the custom template if ?query_type=all_post is found on wordpress url/request
if( $query_var == 'all_post' ){
return get_stylesheet_directory_uri() . 'whatever-filename-you-have.php';
}
return $template;
}
add_filter('template_include', '_template_loader');
You should then be able to access yoursite.com/index.php?query_type=all_post&uname=username or yoursite.com/all-post/user/username
and it should display whatever you put on that php file.
Now that you have the custom url and custom php file, you can start creating your custom query inside the php file to query post type based on user_nicename/author_name,
e.g.
<?php
// get the username based from uname value in query var request.
$user = get_query_var('uname');
// Query param
$arg = array(
'post_type' => 'books',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
'author_name' => $user;
);
//build query
$query = new WP_QUery( $arg );
// get query request
$books = $query->get_posts();
// check if there's any results
if ( $books ) {
echo '<pre>', print_r( $books, 1 ), '</pre>';
} else {
'Author Doesn\'t have any books';
}
I'm not sure why you need to build a custom query for all post as the default author profile loads all the default posts.