Home › Forums › Front-end Issues › Orderby Post Object Title, not Post_ID? › Reply To: Orderby Post Object Title, not Post_ID?
The relationship field => author is stored in the database as a post ID. (if it is a post object field, it’s an array of post IDs if it’s a relationship.)
On top of that, if I understand you correctly, you are trying to order your publication posts by the title of your author posts. So you’re trying to order the posts by the title of other posts. This is not going to be possible using just a WP query.
You’re going to need to get all the authors in the order you want them. Then you’re going to need to get all the publications and then you’re going to have to figure out how to order the publications by the authors. While possible, that’s complicated just to think about.
You could create an acf/save_post action and in that action you could get the selected author, get the authors name and store the name in another custom field using update_post_meta(). I would hide this field by adding an _ to the beginning like _author_name The you could sort your publications by this hidden custom field. This would be a lot less work then trying to sort post by the titles of related posts.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.