Support,
I have this link as a button on my homepage to view my editors pick's: hidden link
After clicking that link I get directed to a page that displays the archives for editors picks. I have an archive template created and set for categories, but is it possible to have a different template display for the category editors picks, while keep the template for the other categories archives?
Thank,
Chuck
Dear Chuck,
You can try with Views filter hook "wpv_filter_force_wordpress_archive".
For example, use above filter hook to trigger a custom PHP function, in this function, check if current page is the editors pick's term archive page:
https://developer.wordpress.org/reference/functions/is_tax/
Then return another specific archive view ID.
More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_wordpress_archive
Filters the ID of the WordPress Archive to be used on a given archive loop.
I understand.
As I'm not a PHP writer, can you assist me with this?
Assuming it would look something like this:
add_filter( 'wpv_filter_force_wordpress_archive', 'my_callback_function', 30, 2 );
function is_tax( $taxonomy = '', $term = '' ) {
global $wp_query;
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return false;
}
return $wp_query->is_tax( $taxonomy, $term );
}
The ID for the editors-picks archive is: 10054
Appreciated,
Chuck
For example, you can try to add below codes into your theme/functions.php:
add_filter( 'wpv_filter_force_wordpress_archive', 'editors_picks_archive_func', 30, 2 );
function editors_picks_archive_func( $wpa_assigned, $wpa_loop ) {
if ( is_tax( 'category', 'editors-picks' ) ) {
$wpa_assigned = 10054;
}
return $wpa_assigned;
}
Thanks Luo.
The code looks promising, but did not return the desired result.
Do I need to set a Loop Selection or Query Filter? I assume this function picks the up automatically, so they should be left blank?
Thanks,
Chuck
It is only an example, you will need to customize the codes according to your website site setttings, Since it is a custom codes problem, if you still need assistance for it, please provide a test site with same problem, fill below private message box with login details and ftp access, I need a live website to test and debug
I tried the FTP access you provided above, it is not valid, I get this error:
Response: 530 Login authentication failed
please check it, make sure it is valid, then update this thread. thanks
Luo,
Those credentials are correct. They're autosaved in toolset. Can you try again?
Yes, I tried lots of time, it is not valid for me, here is the FTP logs:
Command: USER info@artilliodesigns.com
Response: 331 User info@artilliodesigns.com OK. Password required
Command: PASS **********
Response: 530 Login authentication failed
Error: Critical error: Could not connect to server
Please check it
Luo,
Are you able to view my login info from this post: https://toolset.com/forums/topic/pagination-to-only-show-single-view-on-next-page/
You'll see it's the same. I would double check case sensitivity and make sure you're including the period for the end of the password.
Let me know if you're having trouble.
Regards,
Chuck
The FTP access is not valid, so I edit your PHP codes in the wordpress dashboard-> Appearance-> Editor, to below:
add_filter( 'wpv_filter_force_wordpress_archive', 'editors_picks_archive_func', 99, 2 );
function editors_picks_archive_func( $wpa_assigned, $wpa_loop ) {
if ( is_category( 'editors-picks' ) ) {
$wpa_assigned = 10054;
}
return $wpa_assigned;
}
Please test again, check if it is fixed or not, more help:
https://developer.wordpress.org/reference/functions/is_category/