Created
January 9, 2025 08:12
-
-
Save benpearson/677313504ecbdf12451068cae0cf0d99 to your computer and use it in GitHub Desktop.
Wordpress: Full width template conditional helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Helpers: Page Templates | |
*/ | |
function dt_is_full_width_template($post_id) { | |
if (!$post_id) { | |
return false; | |
} | |
$wide_templates = [ | |
'templates/page-full-width.php', | |
]; | |
$post_type = get_post_type($post_id); | |
if ($post_type == 'ei_location') { | |
return true; | |
} | |
if (in_array($post_type, ['page', 'ei_seo_page'])) { | |
$page_template_slug = get_page_template_slug($post_id); | |
if (in_array($page_template_slug, $wide_templates)) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment