Problem: Using PHP, I would like to know if the current page is a custom post type archive, and I would like to be able to determine the name of the Content Template applied to the current page.
Solution:
Use the native WordPress function is_post_type_archive() to determine if the current page is a post type archive:
if ( is_post_type_archive( 'my-custom-post-type-slug' ) ) {
// do something
}
Use the wpv_filter_content_template_output filter to determine the assigned Content Template, and assign that value to a global variable. Then access the title of the Content Template post using get_the_title() since Content Templates are technically posts:
add_filter( 'wpv_filter_content_template_output', 'get_content_template_id', 99, 4 );
function get_content_template_id( $content, $template_selected, $id, $kind ) {
global $current_archive_template_id;
$current_archive_template_id = $template_selected; // $template_selected = current Content Template ID
return $content;
}
// later...
$content_template_title = get_the_title($current_archive_template_id);
We document known issues and their solutions in Toolset errata. Save time by checking there first and seeing if what you are facing is a known issue. This list is kept short. We do our best to resolve all known issues with every release of Toolset plugins.
Support Policy
Toolset staff will help you use the Toolset plugins correctly, provide any information you need, help troubleshoot problems and advice on best-practices.
Please make sure to issue only one topic per each support ticket.