Skip to content

Instantly share code, notes, and snippets.

@messica
Created May 16, 2019 16:38
Show Gist options
  • Select an option

  • Save messica/e3a71ce03911126aae852c9cbcb23bbd to your computer and use it in GitHub Desktop.

Select an option

Save messica/e3a71ce03911126aae852c9cbcb23bbd to your computer and use it in GitHub Desktop.
Register Helper example: custom taxonomy select2 field
<?php
// Get custom taxonomy terms.
$cause_categories = get_terms( array(
'taxonomy' => 'cause-category',
) );
$options = array();
foreach ( $cause_categories as $key => $category ) {
$options[$category->term_id] = $category->name;
}
$fields[] = new PMProRH_Field('cause_category', 'select2', array(
'label' => 'Cause Category',
'profile' => true,
'options' => $options,
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment