Managing Relationships Programmatically
-
I am looking for a programmatic solution to managing relationships from php ($wpdb) or javascript (ajax), but I cannot find online any references or examples of how to do so.
From the admin page, I was able to add a custom post_type called Registration and another one called Events. I set up a relationship field in the Registration post_type called “registered_event”. From the admin screen I can drag and add or remove an event from the Registration post_type, but I would like to do the same programmatically. I cannot find a solution online how to manage relationships programmatically.
When I programmatically create a registration record in the wp_posts table and also create a record in the wp_postmeta table: metakey=”registered_event” and metavalue=”51” (which is the ID for the Event record), the WordPress get_field(“registered_event”) command does not return an array of the Event record. If I manually edit any field of the registration record from the admin screen and save it, then the get_field(“registered_event”) returns the correct data.
How can I manage WordPress relationships programmatically in php ($wpdb) or javascripts (ajax)?The page I need help with: [log in to see the link]
The topic ‘Managing Relationships Programmatically’ is closed to new replies.