apply_filters( 'lp__load_template_parts/{template}', $template_parts, $type )
Allow filtering of template parts to be rendered on a page for a specific template.
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 filtering the template parts to be rendered specifically for a template named your_template. You would replace 'your_template' with the slug or name of your specific template.
// Add the filter hook for customizing the template parts loading for a specific template
add_filter( 'lp__load_template_parts/your_template', function( $template_parts, $type ) {
// Customize the template parts based on specific conditions or requirements for your_template
// Example: Remove a specific template part
unset( $template_parts['your_template_part'] );
return $template_parts;
}, 10, 2 );
After applying this customization, the template parts loaded for the your_template template will be filtered based on the specified conditions. You can modify the $template_parts array inside the filter callback function to include or exclude specific template parts as needed.
Feel free to adjust the template name and modifications inside the filter callback function according to your specific use case.