apply_filters( 'lp__load_template_parts', $template_parts, $template, $type )
Allow filtering of template parts to be rendered on a page.
Plugin
Namespace
Launchpad
Parameters
array
$template_parts
The template parts.
string
$template
The template slug.
string
$type
The template type.
Return
array
The filtered template parts
Example
In this example, we’re customizing the template parts loading specifically for single post pages. We’re adding a custom template part called 'custom_template_part' to the $template_parts array. You would replace 'path/to/custom-template.php' with the actual path to your custom template file.
// Add the filter hook for customizing the template parts loading
add_filter( 'lp__load_template_parts', function( $template_parts, $template, $type ) {
if ( $template === 'single' && $type === 'post' ) {
// Modify $template_parts array as needed
// Example: Add a custom template part for single posts
$template_parts['custom_template_part'] = 'path/to/custom-template.php';
}
return $template_parts;
}, 10, 3 );
After applying this customization, the custom template part will be included in the template parts loaded for single post pages, allowing you to display additional content or modify the layout as needed.
Feel free to adjust the conditions and modifications inside the filter callback function to match your specific use case.