Forums › Forums › Search & Filter Pro › ACF Post Object / Relationship Field
Tagged: acf, query, relationship
- This topic has 2 replies, 2 voices, and was last updated 7 years, 6 months ago by Anonymous.
-
Anonymous(Private) May 9, 2017 at 7:29 am #107537
I understand as of January there is support for ACF Relationship Fields (and as they work the same pretty much I am assuming Post Object field too).
I have everything working almost perfectly. I am setting up a custom results.php page, but I noticed that if I include the ACF recommended loop reset – <?php wp_reset_postdata(); ?> that it monkeys with trying to access individual results post data. For example, <?php the_title(); ?> results in the overarching page title where my results shortcode is, instead of the the title of search/filter post. If that makes sense.
Sooo, should I just remove the query reset, because it works if I do, or will cause other issues? What is the recommended practice in other works for using ACF Relationship field with Search & Filter? Thanks!
Trevor(Private) May 9, 2017 at 10:44 am #107577I understand as of January there is support for ACF Relationship Fields (and as they work the same pretty much I am assuming Post Object field too).
Correct. We still do not support the more complex field types (like repeater). We also do not support the fetching of data from with a related post of a Post Object (so, if that Post Object had a Custom Field with data in, it would not see that). This support simply fetches the related Post ID and Title (I think).
You should not use the ACF documentation for fetching the data in that regard (i.e. do NOT use
wp_reset_postdata()
, as no reset is needed. Our loop does it for you.Anonymous(Private) May 9, 2017 at 1:51 pm #107635Gotcha, thanks for the update. Hopefully ACF Post Object will support Custom Fields with Search & Filter soon too then. 🙂
I guess my code worked because all I was grabbing from the ACF Post Object was the title. Only thing I noticed is I had to pass get_the_title the $post_object var, like so, whereas the ACF instructions didn’t say that was necessary:
<?php $instructor_name = get_the_title( $post ); ?>
And thanks for the confirmation not to use
wp_reset_postdata()
.Cheers!
-
AuthorPosts