I am trying to use include/exclude on my home page only but it doesnt want to play ball.
If i remove the incude array, everything works across all pages, so I know it is my custom function not working.
Any thoughts on where I am going wrong?
This is my function for the custom call
public function evis_include_home( $meta_box ) {
$front_page = (int)get_option( 'page_on_front' );
global $post;
$id = $post->ID;
if ( $id == $front_page )
return true;
return false;
}
And this is my include array
'include' => array (
'relation' => 'AND',
'custom' => 'evisMetaboxes::evis_include_home',
),
The entire class looks like this
<?php
class evisMetaboxes {
function evis_register_home_hero_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array (
'title' => 'Home Page Hero',
'post_types' => array (
'page',
),
'context' => 'normal',
'priority' => 'high',
'status' => 'publish',
'autosave' => false,
'fields' => array (
array (
'id' => 'home_hero_title',
'type' => 'text',
'name' => 'Hero Title',
'std' => 'Evis Resort.',
),
array (
'id' => 'home_hero_tagline',
'type' => 'textarea',
'name' => 'Hero Tagline',
),
array (
'id' => 'home_hero_button',
'type' => 'group',
'name' => 'Hero Button',
'fields' => array (
array (
'id' => 'hero_button_text',
'type' => 'text',
'name' => 'Text',
'std' => 'Explore Evis Resort',
),
array (
'id' => 'home_button_link',
'type' => 'text',
'name' => 'Link',
),
),
'default_state' => 'expanded',
'groupfield' => 'text',
),
),
'id' => 'home-page-hero',
'include' => array (
'relation' => 'AND',
'custom' => 'evisMetaboxes::evis_include_home',
),
);
return $meta_boxes;
}
public function evis_include_home( $meta_box ) {
$front_page = (int)get_option( 'page_on_front' );
global $post;
$id = $post->ID;
if ( $id == $front_page )
return true;
return false;
}
}