Skip to content

Instantly share code, notes, and snippets.

@benpearson
Created January 9, 2025 08:12
Show Gist options
  • Save benpearson/677313504ecbdf12451068cae0cf0d99 to your computer and use it in GitHub Desktop.
Save benpearson/677313504ecbdf12451068cae0cf0d99 to your computer and use it in GitHub Desktop.
Wordpress: Full width template conditional helper
<?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