Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
is_page_template example
$classes
[
]
= 'attachment';
}
if
(
is_404
(
)
)
{
$classes
[
]
= 'error404';
}
if
(
is_singular
(
)
)
{
$post_id
=
$wp_query
->
get_queried_object_id
(
)
;
$post
=
$wp_query
->
get_queried_object
(
)
;
$post_type
=
$post
->post_type;
if
(
is_page_template
(
)
)
{
$classes
[
]
= "{
$post_type
}
-template";
$template_slug
=
get_page_template_slug
(
$post_id
)
;
$template_parts
=
explode
(
'/',
$template_slug
)
;
foreach
(
$template_parts
as
$part
)
{
$classes
[
]
= "{
$post_type
}
-template-" .
sanitize_html_class
(
str_replace
(
array
(
'.', '/'
)
, '-',
basename
(
$part
, '.php'
)
)
)
;
}
$classes
[
]
= "{
$post_type
}
-template-" .
sanitize_html_class
(
str_replace
(
'.', '-',
$template_slug
)
)
;
}
else
{
$classes
[
]
= "{
$post_type
}
-template-default";
}