I’m using this code to add some meta boxes to the home page in WordPress (which is ID 6):
function add_page_metaboxes() {
add_meta_box('meta_p_sub', 'Page Subtitle', 'meta_p_sub', 'page', 'normal', 'high');
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
if ($post_id == '6') {
add_meta_box('meta_hp_thing', 'Homepage Thing', 'meta_hp_thing', 'page', 'normal', 'low');
}
}
add_action('add_meta_boxes', 'add_page_metaboxes');
I want to be able to use this on several sites, and the ID won’t always be ‘6’. I’ve tried to use if (is_home()) {... and if (is_front_page()) {... but that doesn’t seems to work.
How can I find out which ID is set in WP Admin > Settings > Reading > Front Page and use that?
Cheers!
Ben
Front page ID is stored in
page_on_frontoption.