The "How?"
To get rid of a meta box, you got several hooks straight after they were added inside ~/wp-admin/edit-form-advanced.php
. The one you need it 'dbx_post_advanced'
. The you just need to remove the meta box with remove_meta_box()
.
<?php
defined( 'ABSPATH' ) or exit;
/** Plugin Name: (#90253) Remove Page Template Drop Down */
add_action( 'dbx_post_advanced', 'wpse90235_remove_page_template_metabox' );
function wpse90235_remove_page_template_metabox()
{
remove_meta_box( 'pageparentdiv', null, 'side' );
}
That's the only chance doing it.
They "Why?"
The page_attributes_meta_box()
callback that builds the meta box uses wp_dropdown_pages()
and runs the arguments through a filter called 'page_attributes_dropdown_pages_args'
which has two arguments: $dropdown_args
and $post
. When look at the arguments, you'll see that there's the echo
argument set to 0/false
, which shouldn't output anything.
$dropdown_args = array(
'post_type' => $post->post_type,
'exclude_tree' => $post->ID,
'selected' => $post->post_parent,
'name' => 'parent_id',
'show_option_none' => __('(no parent)'),
'sort_column' => 'menu_order, post_title',
'echo' => 0,
);
...Sadly the echo
is forced right after that:
<?php echo $pages; ?>