I'm new to PHP and appreciate any help. I'm trying to understand why $skill is not working on get_post_meta on Wordpress.
I'm trying to calculate (sum) all meta fields numbers in each meta fields = 'ecpt_editorial', 'ecpt_branding', etc. (i.e. = 'ecpt_editoral' has 3 points in one post + 4 points in another one.) I'm trying to calculate them all without need to create a $ to each of them (they're too many).
My errors:
Warning: Illegal offset type in isset or empty in
Fatal error: Unsupported operand types in
<?php $args = array( 'numberposts' => -1, 'post_type' => 'post',);
$points = get_posts( $args );
$total = 0;
$skill = array ('ecpt_editorial','ecpt_branding', 'ecpt_packaging');
foreach( $points as $point ) {
$single = get_post_meta( $point->ID, $skill, false );
$total += $single;}
echo $total;
++$total;
?>
You cant pass in a array to the $key field. This is prob what your looking for:
assuming your not looking to save $single for use?