Skip to content

Instantly share code, notes, and snippets.

@sc0ttkclark
Last active September 25, 2020 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sc0ttkclark/5071618 to your computer and use it in GitHub Desktop.
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.
<?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