I've been trying to add a custom meta box in the Edit Page panel for a page using a specific template, in this case front-page.php
. I have attempted to use both get_page_template_slug( $post_id )
and get_post_meta( $post_id, '_wp_page_template', true )
. But it seems to me that both of these methods merely look for metadata in the database.
Which is a problem, because that's not how my custom template is registered. I've built a custom theme, and I have a page set as the "Front Page", and then a front-page.php
file that Wordpress is automatically assigning to said front page. As far as I can tell, there's nothing in the database that says the front page post uses the front-page.php
template, which is why the above methods don't work.
So, my question is this: if I have a custom theme with custom page templates that are assigned solely by their filenames, how would I detect those templates so I can add custom meta boxes to their respective Edit Panels?
if arr[my-page] then add this meta box