Home › Forums › Feature Requests › Output options for Relationship field
I noticed that when I use the Relationship field, the output is always an WP Post object. Sometimes I want to use the Relationship field (because it offers a great interface for my clients to find the post/page/etc they are looking for), but only output the post ID. (because maybe I only want to put a link on the page, or just the post’s featured image). Then getting the whole postobject would seem a lot of overhead to me…
Hi Hetgelaat!
I think you’ve got a point so I made some alterations to the relationship-field myself 🙂 This will allow you to choose wether to have it return the post objects or just ids
I’ll attach it here. In order to use it simply drop it into plugins/advanced-custom-fields/core/fields and replace the relationship.php
@elliot , I will push this fork for you on github so you can choose to add it in or not 🙂
Great Hetgelaat!
Please mark my answer as the topic solution tho 🙂
Hi Jonathan, I marked my reply as ‘solving the issue’, since then, the buttons to mark YOUR post as the solution have disappeared. Would this be a bug in the forum (@elliot)? or do I miss something?
BTW: the fix was done on the git-source (I suppose), so initially your relationship.php broke the ACF plugin (version 4.2.0). I moved your changes to the relationship.php from 4.2.0 and that worked!
Hi,
Alright 🙂
Yeah Elliot mentioned that it would not be possible for him to simply copy over the entire file since changes had been made to the field in the latest update but rather he had to copy over the changes!
Hey guys,
This is now part of v2.4.1,
Thanks for you help.
Cheers
E
The topic ‘Output options for Relationship field’ is closed to new replies.
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.