Tell us what you are trying to do?
I have created a toolset archive to show Author archive posts. But in the Loop Selection I can't select a specific author to use that archive with. All of the author pages are using that archive. How can I create different different archives for different different authors?
Hello,
There isn't such kind of built-in feature within Toolset plugins, as a workaround you can try with custom PHP codes, you can follow our document to use filter hook "wpv_filter_force_wordpress_archive" to output different WordPress Archive for each author:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_wordpress_archive
More help:
https://developer.wordpress.org/reference/functions/is_author/
Can you kindly provide me the code as I am a non technical guy?
See below test site:
Login URL:
hidden link
1) Create two WordPress Archive:
- Default author archive
hidden link
Assign to "Author archives"
- author1 archive
hidden link
Don't assign it to any loop
2) Add a custom code snippet:
hidden link
with below codes:
add_filter( 'wpv_filter_force_wordpress_archive', function($wpa_assigned, $wpa_loop){
if(is_author(5)){ // specific author user ID
$wpa_assigned = '25'; // specific WordPress Archive ID
}
return $wpa_assigned;
}, 30, 2 );
Test it in frontend:
Author1 archive page:
hidden link
Other author default archive page:
hidden link
For your reference.
My issue is resolved now. Thank you!