Hi, what’s wrong in the above code?
Im trying to pass a variable outside the loop but I get this error:
Trying to get property ‘numero_doc’ of non-object
$posts = new WP_Query( $args );
if( $posts ):
foreach( $posts as $post ):
setup_postdata( $post );
$number = $post->numero_doc;
endforeach;
wp_reset_postdata();
endif;
}
$field['default_value'] = $number + 1;
return $field;
}
What do you think that $post->numero_doc
should be?