I have a parent post type "PROJECT" with several children posts of post type "PRODUCT".
In PRODUCT post type, I have a custom field called "PRICE".
On a single PROJECT page, I need to calculate the sum of PRICES for children PRODUCTS of the actual PROJECT.
I assume I need to create a shortcode that would look like this :
function total_projet( $atts ) {
$totalprojet = 0;
// loop while current post has PRODUCT children
// $totalprojet = $totalprojet + get_post_meta($product_id, 'wpcf-total-ht', true);
// end loop
return $totalprojet;
}
add_shortcode('total-projet', 'total_projet');
Could you please help me getting the child post and build this function ?