• Hello! I am trying to sort CPT’s called “requests” showing from an ACF relationship field in a user archive. I want to order these requests by a number field (priority).

    Can you possibly see what I’m doing wrong here?

    [related request_partner_v2 ][if taxonomy=request_stage term=new,active,qa,on-deck,delivered,planned,revision orderby=field_num key=partner_request_priority order=DESC ]
    <div class=”row”>
    <div class=”col-sm-2″>[field partner_request_client]</div>
    <div class=”col-sm-1″>[field partner_rid]</div>
    <div class=”col-sm-1″>[taxonomy request_stage]</div>
    <div class=”col-sm-1″>[field partner_request_priority]</div>
    <div class=”col-sm-1″>[field partner_request_due date_format=m/d/y]</div>
    <div class=”col-sm-2″>[link][field partner_request_subject][/link]</div>
    <div class=”col-sm-4″>[field partner_request_details]</div>
    </div>
    [/if][/related]

Viewing 8 replies - 1 through 8 (of 8 total)
  • [if] does not support order

    You must use the ID’s from the related field for a loop – there you then can sort.

    Thread Starter Andrew Steelsmith

    (@captaindrew80)

    Thanks for the response. Would I still be able to filter by taxonomy?

    Thread Starter Andrew Steelsmith

    (@captaindrew80)

    Nevermind I answered my own question!

    Here’s what I ended up with:

    [loop field=request_partner_v2 orderby=field_num key=partner_request_priority order=DESC ][if taxonomy=request_stage term=new,active,qa,on-deck,delivered,planned,revision ]
    <div class="row">
    <div class="col-sm-2">[field partner_request_client]</div>
    <div class="col-sm-1">[field partner_rid]</div>
    <div class="col-sm-1">[taxonomy request_stage]</div>
    <div class="col-sm-1">[field partner_request_priority]</div>
    <div class="col-sm-1">[field partner_request_due date_format=m/d/y]</div>
    <div class="col-sm-2"><a href="[url]">[field partner_request_subject]</a></div>
    <div class="col-sm-4">[field partner_request_details]</div>
    </div>
    [/if][/loop]

    Thanks for your help!

    Thread Starter Andrew Steelsmith

    (@captaindrew80)

    Quick followup: It looks like I’m not able to display an acf relationship field within a loop? Instead of [related] do I use [loop] again? Thanks!

    Youi could use a nested loop with [-loop]

    Thread Starter Andrew Steelsmith

    (@captaindrew80)

    Thanks I’ll try that.

    So when I use the IF (taxonomy filter) or the term taxonomy parameter in the loop, it expands the results and shows posts that aren’t included in the relationship field. When I switch back to related (with the IF) it shows the correct posts but I can’t order.

    This is an author archive, and the related posts also have the user as the author, so is there a different way outside of using the acf relationship field to:
    Show all requests (posts) of which the user is the author?
    Be able to filter out certain stages (taxonomies)

    try:

    [loop YOUR RELATIONSHIP FIELD WITH ORDER]
      [-loop YOUR TAXONOMY FIELD]
    
      [/-loop]
    [/loop]

    or the other way round if this destroys your order.

    • This reply was modified 2 years, 10 months ago by polarracing.
    Thread Starter Andrew Steelsmith

    (@captaindrew80)

    When I add the taxonomy in, it not only shows posts that are in the relationship field, but it opens it up to all others as well. That seemed to work the same both ways.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Ordering Posts via ACF Relationship Field’ is closed to new replies.