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!
© 2023 Advanced Custom Fields.