DidouS

20210921-RK-Meta Query in args

Sep 21st, 2021
919
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {% set related_reviewids = tb.get_field( 'homeowner_review' ) %}
  2. {# use WP get_posts to order the selected postids, the 'fields' arg causes query to return us IDs instead of Posts #}
  3. {%
  4.     set args = {
  5.         'post_type' : 'review',
  6.         'post_status': 'publish',
  7.         'numberposts': -1,
  8.         'order': 'DESC',
  9.         'orderby': 'meta_value',
  10.         'meta_key': 'review_date_of_work',
  11.         'fields': 'ids',
  12.         'post__in' : related_reviewids,
  13.         'meta_query' : {
  14.             'relation' : 'AND',
  15.             'company_clause': {
  16.                 'key' : 'companyname',
  17.                 'value' : companyname_to_look_match,
  18.                 'compare' : '=',
  19.                 'type' : 'CHAR',
  20.             }
  21.         }
  22.     }
  23.  
  24. %}
  25. {% set sorted_reviewids = tb.get_posts( args ) %}
RAW Paste Data