Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (17 sloc) 674 Bytes
function shortcode_groups_groups_parent ( $attr = array() ) {
global $wpdb;
$parent_id = isset( $attr['parent_id'] ) ? intval($attr['parent_id']) : 0;
$groups_table = _groups_get_tablename( 'group' );
if ( $parent_id ) {
$groups = $wpdb->get_results( "SELECT * FROM $groups_table WHERE parent_id = " . $parent_id . " ORDER BY name" );
} else {
$groups = $wpdb->get_results( "SELECT * FROM $groups_table ORDER BY name" );
}
$output = '<ul>';
foreach ($groups as $group) {
$output .= '<li>' . $group->name . '</li>';
}
$output .= '</ul>';
return $output;
}
add_shortcode('groups_groups_parent', 'shortcode_groups_groups_parent');
You can’t perform that action at this time.