- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › Back End › Recieving error message when trying to set up metaboxes from a github script
I am trying to use a meta box script from//
https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/blob/master/readme.md
&I know it says “This script is easy to install. If you can’t figure it out you probably shouldn’t be using it.”
But I really need this so I hope to get it working soon…
Anyway, I included the ‘init.php’ in my functions.php file like so//
add_action('init', 'include_init_file');
function include_init_file() {
require_once get_stylesheet_directory() . '/lib/metabox/init.php';
}
I uploaded the files to “lib/metabox”.
I created a custom post type and used the code in this pastebin to do so, which includes some code from example-functions.php//
http://pastebin.com/bp5bvTnE
But when I try to test it out I am left with this error message//
“Warning: Invalid argument supplied for foreach() in /home/xxx/public_html/xxx/testing/wp-content/themes/xxx/lib/metabox/init.php on line 46“
Can someone please help me fix this?
function custom_meta_boxes_and_fields()
{
require get_template_directory() . '/lib/metabox/init.php';
}
add_action('init', 'custom_meta_boxes_and_fields');
I’ll test some of the code once on my machine, but from the error it seems like you’re not passing in data correctly, as the foreach() is expecting an array.
Are you following the Wiki: https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress/wiki/Basic-Usage