Skip to main content
added 636 characters in body
Source Link
Chip Bennett
  • 55.1k
  • 8
  • 90
  • 170

Problem #1:

First problem: inside home-meta.php, pull all of your add_meta_box() calls outside of the add_meta_boxes_home() callback, and get rid of the callback and add_action() call. You handle this already, with the add_meta_boxes_page callback in functions.php, that includes home-meta.php.

Problem #2:

Warning: Invalid argument supplied for foreach() in /Users/[my_mac]/Sites/[site_dir]/wp-content/themes/[site_theme]/metaboxes/home-meta.php on line 224

Assuming that this is line 224:

foreach ($home_meta_fields as $field) {

I think the problem is that you globalize $home_meta_fields after you define it:

$home_meta_fields = array( ... );

...later followed by:

global $home_meta_fields, $post;
foreach ( $home_meta_fields as $field ) {

Try globalizing $home_meta_fields before you define it:

global $home_meta_fields;
$home_meta_fields = array( ... );

...then it should be recognized as a valid, set array in your foreach() call.

First problem: inside home-meta.php, pull all of your add_meta_box() calls outside of the add_meta_boxes_home() callback, and get rid of the callback and add_action() call. You handle this already, with the add_meta_boxes_page callback in functions.php, that includes home-meta.php.

Problem #1:

First problem: inside home-meta.php, pull all of your add_meta_box() calls outside of the add_meta_boxes_home() callback, and get rid of the callback and add_action() call. You handle this already, with the add_meta_boxes_page callback in functions.php, that includes home-meta.php.

Problem #2:

Warning: Invalid argument supplied for foreach() in /Users/[my_mac]/Sites/[site_dir]/wp-content/themes/[site_theme]/metaboxes/home-meta.php on line 224

Assuming that this is line 224:

foreach ($home_meta_fields as $field) {

I think the problem is that you globalize $home_meta_fields after you define it:

$home_meta_fields = array( ... );

...later followed by:

global $home_meta_fields, $post;
foreach ( $home_meta_fields as $field ) {

Try globalizing $home_meta_fields before you define it:

global $home_meta_fields;
$home_meta_fields = array( ... );

...then it should be recognized as a valid, set array in your foreach() call.

Source Link
Chip Bennett
  • 55.1k
  • 8
  • 90
  • 170

First problem: inside home-meta.php, pull all of your add_meta_box() calls outside of the add_meta_boxes_home() callback, and get rid of the callback and add_action() call. You handle this already, with the add_meta_boxes_page callback in functions.php, that includes home-meta.php.