Skip to content

Use get_stylesheet_directory() for override folders in child theme #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JSn1nj4
Copy link

@JSn1nj4 JSn1nj4 commented Mar 30, 2023

Issue

When a child theme is active, the TypeRocket plugin will currently check the parent theme for override folders. This is because the function get_template_directory() will find the parent of a child theme if a child theme is active.

Source: get_template_directory() function

In the case a child theme is being used, the absolute path to the parent theme directory will be returned. Use get_stylesheet_directory() to get the absolute path to the child theme directory.

Solution

Use the function get_stylesheet_directory() instead as recommended by the above docs.

@JSn1nj4
Copy link
Author

JSn1nj4 commented Mar 30, 2023

I realized this morning that this isn't foolproof. It does handle the case of a child theme being the active one, but it won't fall back to the parent theme if the child theme doesn't have the override folders.

Do you prefer covering both cases?

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

Successfully merging this pull request may close these issues.

1 participant