Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

remove page template slug from body class #90

Merged
merged 1 commit into from
May 10, 2015
Merged

remove page template slug from body class #90

merged 1 commit into from
May 10, 2015

Conversation

kevinlisota
Copy link
Contributor

The current version of Soil inserts a body class by calling get_page_template().

get_page_template() actually returns page.php when it doesn't find a page template. It does this for everything, including posts. Soil then strips off the .php extension and inserts the class "page" where it doesn't belong. This is particularly problematic if you use .post and .page as CSS selectors, which many people do. The only page that should have the class "page" in WP is a page.

We could add a conditional check to watch for pages, or could use get_template_slug(), which doesn't fall back to page.php here, and only returns a template slug if one is set. However, I propose that we delete it completely.

WP already outputs the page template slug as a body class, if a page template is set. It is a bit longer, but still can be used, for example page-template-template-name. This function is actually introducing unnecessary duplication in the body class, by also inserting "template-name", without the "page-template" bit. Seems unnecessary to include two classes for the same page template, unless I'm missing the use case here.

The current version of Soil inserts a body class by calling get_page_template().

get_page_template() actually returns page.php when it doesn't find a page template. It does this for everything, including posts. Soil then strips off the .php extension and inserts the class "page" where it doesn't belong. This is particularly problematic if you use .post and .page as CSS selectors, which many people do. The only page that should have the class "page" in WP is a page.

We could add a conditional check to watch for pages, or could use get_template_slug(), which doesn't fall back to page.php here, and only returns a template slug if one is set. However, I propose that we delete it completely. 

WP already outputs the page template slug as a body class, if a page template is set. It is a bit longer, but still can be used, for example page-template-template-name. This function is actually introducing unnecessary duplication in the body class, by also inserting "template-name", without the "page-template" bit. Seems unnecessary to include two classes for the same page template, unless I'm missing the use case here.
retlehs added a commit that referenced this pull request May 10, 2015
remove page template slug from body class
@retlehs retlehs merged commit bfb4d37 into roots:master May 10, 2015
@retlehs
Copy link
Member

retlehs commented May 10, 2015

thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants