Problem: I would like to apply different Content Templates to the same Custom Post Type depending on the current User's custom field value, or User role, or some other criteria.
Solution: We offer a filter that will allow you to programmatically override the default Content Template - wpv_filter_force_template:
add_filter( 'wpv_filter_force_template', 'dynamic_author_template_for_post_12345', 99, 3 ); function dynamic_author_template_for_posts( $template_selected, $id, $kind ) { if ( $id == 12345 ) { // if the user is trying to view the post with ID 12345 $template_selected = get_the_author_meta('wpcf-template-field-slug'); } return $template_selected; }
Relevant Documentation: https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_template
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 3 replies, has 3 voices.
Last updated by 7 years, 2 months ago.
Assisted by: Christian Cox.