acf-2way-pr
acf-2way-pr copied to clipboard
Help using this plugin
For anyone using this plugin, i had some trouble due to the lack of documentation and comments. So here's what i found for anyone else:
Bi-directional relationship fields work the same as acf relationship fields by:
- Setting up the same way in
custom fields
- Using the same way while editing a post
How i thought it would work, but doesn't:
3. There's no admin link between bi-directional, e.g: In custom fields
if you add a relationship in post type 1
, and a similar relationship in post type 2
, these are not linked, and can't be viewed from each other's edit page.
This plugin essentially adds the relationship data from post type 1
to the acf post data of the post selected in the relationship, using the field name of the relationship. No admin view that reflects this. It just adds the meta data into post type 2
for using in your template.
I cannot see any relations in the DB. How would I test if it is working. As you mention, nothing is visible in the admin-area.
I have a custom post type called clients, and another one called showcases. When publishing a new showcase I want it to have a relationship to a client. But if there is no to-way relation here then I won't be able to pull all showcases of a certain client.
From memory (might be a little rusty):
Relationships just store post_name, post_id, permalink, slug etc (very basic post data), but no custom field data. So at most you can list your related posts, and have links to them.
If you want to use the ACF data for each related post, you need to grab the ID's of those posts from your relationship, put them into an array, and do another WP_Query with just those IDs. Then you can loop through like normal.
If you want to see the data, you can use WP API, find your correct endpoint, and you should be able to view what relationship data was stored.
http://v2.wp-api.org/
The result gets printed out in JSON, so you might want to install an extension for your browser that can view JSON. Or copy and paste the code here:
http://codebeautify.org/jsonviewer
Hope that helps