I’m trying to limit the post meta to specific template.
This code seems to do the trick
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
$template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
but when running a debug I get the Undefined index: post_ID/post error.
Is there an alternative or can you help me fix this?
EDIT:
Wrapped whole code with if (isset($_GET['post'])) and that fixed it for me.
With your ternary to avoid a warning you probably want
Which will check to see if the value post exists in
$_GET['post']before trying to do this, while not raising a warning.