Function Reference: geodir_get_template_part

Summary

Locates template part based on the template slug.

Global Values

$post
(object) (required) The current post object.

Default: None
$geodirectory
(object) (required) Not yet implemented.

Default: None

Package

GeoDirectory

Parameters

$slug
(string) (required) The template slug.

Default: None
$name
(null) (required) The template name.

Default: None

Change Log

Since: 1.0.0

Actions

‘geodir_get_template_part_{$slug}’ [Line: 442]

Filters

‘geodir_template_part-{$slug}-{$name}’ [Line: 459]

Source File

geodir_get_template_part() is located in geodirectory-functions/template_functions.php [Line: 429]

Source Code

function geodir_get_template_part($slug = '', $name = NULL)
{
    global $geodirectory, $post;
    /**
     * Called at the start for the geodir_get_template_part() function.
     *
     * Used dynamic hook name: geodir_get_template_part_{$slug}
     *
     * @since 1.0.0
     * @package GeoDirectory
     * @param string $slug The template slug.
     * @param string $name The template name.
     */
    do_action("geodir_get_template_part_{$slug}", $slug, $name);
    $templates = array();
    $name = (string)$name;
    if ('' !== $name) {
        $template_name = "{$slug}-{$name}.php";

    } else {
        $template_name = "{$slug}.php";
    }

    if (!locate_template(array("geodirectory/" . $template_name))) :
        /**
         * Filter the template part with slug and name.
         *
         * @since 1.0.0
         * @param string $template_name The template name.
         */
        $template = apply_filters("geodir_template_part-{$slug}-{$name}", geodir_plugin_path() . '/geodirectory-templates/' . $template_name);
        /**
         * Includes the template part with slug and name.
         *
         * @since 1.0.0
         */
        include($template);
    else:
        locate_template(array("geodirectory/" . $template_name), true, false);
    endif;

}