DidouS

20210730-RK-Altered Homeowner Review

Jul 30th, 2021
1,595
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. {# will return a set of postids #}
  3. {% set related_reviewids = tb.get_field( 'homeowner_review' ) %}
  4. {# use WP get_posts to order the selected postids, notice the 'fields' arg that will only return us IDs instead of Posts #}
  5. {%
  6.     set args = {
  7.         'post__in' : related_reviewids,
  8.         'numberposts': -1,
  9.         'order': 'ASC',
  10.         'orderby': 'meta_value_datetime',
  11.         'meta_key': 'review_date_of_work',
  12.         'fields': 'ids',
  13.     }
  14. -%}
  15. {% set sorted_reviewids = tb.get_posts( args ) %}
  16. %}
  17. {% for related_post_id in sorted_reviewids %}
  18.     {# get a Timber Post Object using this Post ID and set as variable 'item' #}
  19.     {% set the_review = Post(related_post_id) %}
  20.     {% if the_review.post_status == "publish" %}
  21.         {# you can now access properties of item as a normal Timber Object #}
  22.         <h3>{{ the_review.review_date_of_work|date("m/d/Y") }}</h3>
  23.          
  24.         <br>
  25.  
  26.         {% set review_contractor = tb.get_field( 'review_contractor' , related_post_id ) %}
  27.         {% set contractor_url = '/members/' ~ review_contractor.user_nicename ~ '/profile' %}
  28.         <p><strong>Contractor:</strong> <a href="{{ contractor_url }}">{{ review_contractor.first_name }} {{ review_contractor.last_name }}</a></p>
  29.  
  30.         {% set review_work_type = tb.get_field( 'review_type_of_work' , related_post_id )[0] %}
  31.         <p><strong>Work Type:</strong> {{ tb.get_the_title(review_work_type) }}</p>
  32.          
  33.         <p><strong>Ratings:</strong> Payment={{ the_review.review_payment }}, Ease={{ the_review.review_easy_to_deal_with }}, Complaints={{ the_review.review_complaints }}, Scope={{ the_review.review_scope_creep }}, Work Again={{ the_review.review_work_again }}</p>
  34.          
  35.         {% set review_url = '/review/' ~ the_review.slug %}
  36.         <p><a href="{{ review_url }}">See full review</a></p>
  37.          
  38.         <hr>
  39.     {% endif %}
  40. {% endfor %}
RAW Paste Data