我正在尝试运行WPDB查询以计算post meta的值:
Sum meta Value by post_id which have post_parent = xx
我有一个WPDB代码,但我不知道如何通过post_parent:
$wpdb->get_results("SELECT SUM($wpdb->postmeta.meta_value)
FROM $wpdb->postmeta WHERE `post_id` = get_the_ID()");
答案 0 :(得分:-1)
$wpdb->get_results("SELECT SUM( wp_postmeta.meta_value )
FROM wp_postmeta
WHERE wp_postmeta.post_id =".get_the_ID());