Home Forums Feature Requests Output options for Relationship field


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

    , I will push this fork for you on github so you can choose to add it in or not 🙂

  • Hi @Jonathan

    Thanks mate, I’ll add this in!

  • You guys are awesome! This is exactly what I had in mind!

  • 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.


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

The topic ‘Output options for Relationship field’ is closed to new replies.