Home › Forums › Backend Issues (wp-admin) › Invalid Array from Relationship Field Type › Reply To: Invalid Array from Relationship Field Type
Thanks so much for your reply.
The errors that are thrown back with invalid argument relate to three uses of this code.
On our site’s homepage, the latest post is shown and uses a version of this code from a loop-index.php. On the homepage there is also a use by a postslider.php insert that shows other recent content. Then on each post the code is used by the header.php. So I suppose the answer is both? Site is religiousstudiesproject.com/
I believe the check for is_single() makes sure that if an editor/user did not specify a ‘person’ in content creation that their username appears as the author. Otherwise this code uses the ACF relationship field supplied ‘persons’ for authorship.
I tried several things this morning, including changing the construction of the $acfield variable from
$acfield = get_field('persons', $current_post_id); to
$acfield = get_field('persons'); since I wondered whether it was necessary to specific $current_post_id when the get_field was already returning a post id by default.
I then saw an old support ticket suggesting the $acfield’s construction needed to be inside the foreach(). That didn’t help either.
Neither of those changes broke the code, nor did they stop the errors. I simply don’t understand enough about why or how the argument is invalid to move forward with a solution.
[Sidebar: I’m redoing the site and hope to fix the source of these custom php errors by using ACF, elementor and a dynamic content plugin that will give us greater flexibility on the appearance of this part of our site]
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!
🗓️ Just one more day until the next session of ACF Chat Fridays! Make sure to register for the latest updates on what’s coming in ACF 6.1!— Advanced Custom Fields (@wp_acf) March 30, 2023
📆 Friday 31st March 3pm UTC
👉 Register here - https://t.co/3UtvQbDwNm pic.twitter.com/7xtEJakeQN
© 2023 Advanced Custom Fields.