Home > AI > Backend > Wordpress >

locate_template

see if this template file exists.

$exists = locate_template("templates/header-".$post_type.".php");

if ($exists != "") {
    get_template_part("templates/header", $post_type);
} else {
    get_template_part("templates/header", "common");
}

Leave a Reply