Function Signature:
get_post_type_archive_template
Function Description:
Retrieves path of post type archive template in current or parent template.
Function Examples:
⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Retrieve the archive template for the 'book' custom post type
$post_type = 'book';
$template = get_post_type_archive_template( $post_type );
if ( $template ) {
include( $template );
} else {
echo 'Template not found';
}
// Example 2: Get the archive template for the current post type
$post_type = get_post_type();
$template = get_post_type_archive_template( $post_type );
if ( $template ) {
include( $template );
} else {
echo 'Template not found';
}
// Example 3: Retrieve the archive template for the 'product' custom post type and fallback to the default archive template if not found
$post_type = 'product';
$template = get_post_type_archive_template( $post_type );
if ( $template ) {
include( $template );
} else {
$default_template = get_archive_template();
include( $default_template );
}