Timeline for How to get sum of meta_values of a meta_key in wp_query according to conditions
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 4, 2022 at 14:09 | comment | added | Dennis van Schaik | This should be the accepted answer | |
S Sep 10, 2020 at 5:57 | history | suggested | user3445853 | CC BY-SA 4.0 |
PHP tag not wanted/needed + "global" declaration needed
|
Sep 9, 2020 at 17:08 | comment | added | user3445853 |
The weakness/error here however is that you are counting values for all posts --- all post types, draft or published, public or private --- and cannot sort the unwanted out as in the accepted (WP_query + loop) answer... So the OP has to adapt this answer by joining the table $wpdb->postmeta to $wpdb->posts , so the WHERE clause gets AND post_type = 'rented_properties' (and maybe also AND post_status = 'published' .
|
|
Sep 9, 2020 at 17:00 | comment | added | user3445853 |
I can confirm this works as long as you declare global $wpdb .
|
|
Sep 9, 2020 at 16:50 | review | Suggested edits | |||
S Sep 10, 2020 at 5:57 | |||||
Feb 19, 2017 at 1:11 | review | Late answers | |||
Feb 19, 2017 at 8:02 | |||||
Feb 19, 2017 at 0:53 | review | First posts | |||
Feb 19, 2017 at 0:55 | |||||
Feb 19, 2017 at 0:53 | history | answered | user113667 | CC BY-SA 3.0 |