Last active
September 25, 2020 18:14
-
-
Save sc0ttkclark/5071618 to your computer and use it in GitHub Desktop.
In Pods 2.3, you can now add custom relationship objects quickly and easily. Add predefined lists, integrate with other plugins and their data, or do whatever you want just about! The custom relationships will appear in the 'Relate to' options for a Relationship Field. This is a simple example meant for basic key/value data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', 'add_my_related_objects' ); | |
function add_my_related_objects () { | |
$options = array( | |
'data' => array( | |
1 => 'Option 1', | |
2 => 'Option 2' | |
) | |
); | |
pods_register_related_object( 'my-custom-relationship', 'My Custom Relationship', $options ); | |
$options = array( | |
'data' => array( | |
'male' => 'Male', | |
'female' => 'Female', | |
'not-specified' => 'Not Specified' | |
) | |
); | |
pods_register_related_object( 'gender', 'Gender', $options ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment