Unload templates; disable parent Template Parts using only “theme.json”

Does anyone have any suggestions on how to disable certain template parts in a child theme using theme.json in WordPress with Gutenberg? Using only theme.json this is not possible, and runs counter to the vision for full site editing. In the future it’s possible that not only the parent theme templates might be visible, but … Read more

I’m building a WordPress theme and noticed that the 404 page template runs along with the corresponding templates for each page. Any idea why?

I used the following function to retrieve the URLs of each page. function template_debug($filename = null) { $url = home_url($_SERVER[‘REQUEST_URI’]); debug(“Called from: $filename using URL $url \n”); } Then I inspected the front page which triggered the 404 template along with the front-page template. The Network Monitor tab showed the error, which was an incorrect … Read more

Archive for custom fields?

WordPress does not support by default custom_fields archive like for taxonomies (yeah, taxonomies can have categories) but we can create a destination page with page template (linked from the listed custom_field) and added a searching on the custom_field, like this (from the listing page): <?php if (get_post_meta($post->ID,’_my_meta’,TRUE)) : $key_meta = get_post_meta($post->ID,’_my_meta’,TRUE); endif; ?> <a href=”https://wordpress.stackexchange.com/questions/92473/<?php … Read more

Get the current hierarchy php page

Assuming that you’re wanting to determine which template page is currently being displayed, within the template hierarchy, the easiest way to do so is via the output of body_class(). However, if you need to return this information programmatically, the easiest way might be to call get_body_class(), and then evaluate the array of classes returned. Given … Read more