[wp-trac] [WordPress Trac] #57422: get_body_class() adding class "{$post_type}-template-{dir}{file}"
WordPress Trac
noreply at wordpress.org
Thu Jan 5 10:41:39 UTC 2023
#57422: get_body_class() adding class "{$post_type}-template-{dir}{file}"
---------------------------+-------------------------------
Reporter: arrancurran | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 6.1.1
Severity: minor | Keywords: changes-requested
Focuses: css, template |
---------------------------+-------------------------------
When is_singular() and is_page_template() and the template file is inside
a directory within the theme folder, get_body_class() adds a class with a
missing hyphen between the template directory and the template file name.
post-template.php line 677;
$classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace(
'.', '-', $template_slug ) );
Example: post_type is page and template file is, "page-templates/my-
template-file.php"
Result: .page-template-page-templatesmy-template-file-php
Suggested change to post-template.php line 677;
$classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace(
array( '.', '/' ), '-', $template_slug ) );
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57422>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list