Support

Account

Home Forums ACF PRO Use Post Object Field For Ordering

Helping

Use Post Object Field For Ordering

  • I’m want to use the title of a post object field to sort the results of a query but currently it seems to use the postid rather than the title:

    ‘orderby’ => ‘meta_value’,
    ‘meta_key’ => ‘raceyear’,
    ‘order’ => ‘DESC’,

    This make sense knowing how the data is stored but was wondering if it were possible to use the post title instead somehow?

  • You cannot sort of the title of the post object. The only thing that ACF stores about the post object field is the ID. The same principle applies for something like this as I posted about repeater sub fields here https://acfextras.com/dont-query-repeaters/

    basically what you need to do is to create an acf/save_post filter, get the post object field and save the title of that post object as custom meta value associated with the post you want to be able to sort.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Use Post Object Field For Ordering’ is closed to new replies.