I am having some problems including files for my custom meta boxes. I have a structure like so:
post-meta.php
cmb
- teaser_meta_box
- load.php
- initiate.php
- display.php
- save.php
So within my post-meta.php I have the following includes:
// Load Meta Boxes
function add_custom_meta_box()
{
require_once dirname( __FILE__ ) . '/cmb/teaser_meta_box/load.php';
}
add_action('add_meta_boxes', 'add_custom_meta_box');
// Initiate Meta Box Fields
require_once dirname( __FILE__ ) . '/cmb/epteaser_meta_box/initiate.php';
// Display Meta Box Fields
require_once dirname( __FILE__ ) . '/cmb/epteaser_meta_box/display.php';
// Save Meta Box Fields
function save_custom_meta($post_id)
{
global $meta_fields_epteaser, $post; // Need to put name of each meta field here
// verify nonce
if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))
return $post_id;
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
// check permissions
if ('page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id))
return $post_id;
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
require_once dirname( __FILE__ ) . '/cmb/epteaser_meta_box/save.php';
}
add_action('save_post', 'save_custom_meta');
When I try this the meta boxes do not work how they should, however I do not get any errors saying includes are wrong etc. If I try to put the code directly into the file for initiating and displaying the meta box it then works.
Any ideas as to why these two includes dont seem to work when included?
Thanks Robert