I'd like to modify the admin so the default text editor is removed whenever someone is using the default template. (If they manually choose something other than the default, keep the editor).
if ($currentPage == 'Default Template') {
remove_post_type_support( 'page', 'editor' );
}
So I am looking for a way to determine the selected page template on load and perform an action based on that. I am trying to do something If I run this query:
add_action('init', function () {
var_dump(wp_get_theme()->get_page_templates());
});
On a new theme it returns an array with template-custom.blade.php
. But when I run this:
add_action('init', function () {
var_dump(get_page_template());
});
It returns page.php
. If I switch the page to "Custom Template" and save. Even on reload it still returns page.php
. What are my options?
I also tried this method in init
didn't work either.
$template_filename = get_post_meta( get_the_ID(), '_wp_page_template', true );
AFAIK, I should remove_post_type_support
during the init
hook, but wondering if the template information is available yet.