lp__load_template_parts( $parts, $callback, $template, $type )

This function allows you to load multiple template parts based on an array of template slugs and names. You can specify the parts you want to load for a specific page or section. The function provides flexibility to customize the templates to be loaded on a page by utilizing the `lp__load_template_parts` filter hook.

Plugin

Namespace

Launchpad

Parameters

array

$parts

Array of template parts to load.

callable

$callback

Callback function to execute after loading the template parts.

string

$template

Template name or identifier (e.g., file name or page slug).

string

$type

Type of template parts being loaded (e.g., ‘block’, ‘section’, ‘partial’).

Return

void

Source

File: \includes\lp-utility-functions.php

function lp__load_template_parts( $parts, $callback, $template, $type ) {

    /**
     * Filters: lp__load_template_parts/{$template}/{$type}.
     *
     * Allow filtering of template parts to be rendered on a page for a specific template and type.
     *
     * @since 1.5.0
     *
     * @param array  $parts     The template parts.
     * @return array            The filtered template parts.
     */
    $template_parts = apply_filters( "lp__load_template_parts/{$template}/{$type}", $parts );

    /**
     * Filters: lp__load_template_parts/{$template}.
     *
     * Allow filtering of template parts to be rendered on a page for a specific template.
     *
     * @since 1.5.0
     *
     * @param array  $template_parts  The template parts.
     * @param string $type            The template type.
     * @return array                  The filtered template parts.
     */
    $template_parts = apply_filters( "lp__load_template_parts/{$template}", $template_parts, $type );

    /**
     * Filters: lp__load_template_parts.
     *
     * Allow filtering of template parts to be rendered on a page.
     *
     * @since 1.5.0
     *
     * @param array  $template_parts  The template parts.
     * @param string $template        The template slug.
     * @param string $type            The template type.
     * @return array                  The filtered template parts.
     */
    $template_parts = apply_filters( "lp__load_template_parts", $template_parts, $template, $type );

    if ( $callback && is_callable( $callback ) ) {
        $callback( $template_parts );
    }
}

Related

Used to standardize file paths by replacing backslashes and removing duplicates.

Used to retrieve the normalized file path of a plugin file.

Used to include Launchpad plugin files via require_once based on filename and plugin name.

Used to retrieve and load plugin template based on slug and name.

Use to search for template files in theme and plugin directories.

Use to load multiple template parts based on slugs and names.