I have a Relationship Field called “Featured Content” by which I can select posts from many different Custom Post Types to build a feaured section.
I set the options to display both the Thumbnail and the Post Type in the list, so it looks like this:
So far so good!
But when I click on Save or Update the post/page, it replaces the correct Post Types of the added contents by the Post Type of the post/page the Relationship field is in (in this case it is in a page). Like this:
Is this the intended behaviour?
Otherwise, anyone can guess what’s going on?
P.S.: I’ve been working on this site for some months, and I created this relationship field a while ago, so I can’t remember how it was working, but I guess it was working fine, otherwise I’d have realized this problem before…
I tried to create different Relationship fields, with different options, in different pages, and nothing is working.
I also tried to “downgrade” WordPress to 3.8.x and the ACF plugin to 4.3.5, and it’s still not working…
Unfortunately I didn’t so far.
Actually I’ve not worked on that particular issue since I wroted the question, but I guess if I don’t receive any better suggestion, I’ll try to use the filter acf/fields/relationship/result to customize the HTML correctly. I’d try to grab the post type of each row and manually set the correct text for each row.
I think that should work. I’ll comment when I try…
The actual bug is in advanced-custom-fields/core/fields/relationship.php in line 496:
At the moment it is:
$post_type_object = get_post_type_object( get_post_type( ) );
And it should actually be:
$post_type_object = get_post_type_object( get_post_type( $p->ID ) );
Otherwise it is getting the post type of the current post, intead of the selected post for the relationship block…
You must be logged in to reply to this topic.
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!
© 2023 Advanced Custom Fields.