Function Reference: geodir_imex_get_terms
Summary
Retrieve terms for given post type.
Package
GeoDirectory
Parameters
- $post_type
- (string) (required) The post type.
- Default: None
- $per_page
- (int) (required) Per page limit.
- Default: 0
- $page_no
- (int) (required) Page number.
- Default: 0
Return Values
- (array)
- Array of terms data.
Change Log
Since: 1.4.6
1.5.7 $per_page & $page_no parameters added.
Source File
geodir_imex_get_terms() is located in geodirectory-admin/admin_functions.php [Line: 5615]
Source Code
function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) { $args = array( 'hide_empty' => 0, 'orderby' => 'id' ); remove_all_filters( 'get_terms' ); $taxonomy = $post_type . 'category'; if ( $per_page > 0 && $page_no > 0 ) { $args['offset'] = ( $page_no - 1 ) * $per_page; $args['number'] = $per_page; } $terms = get_terms( $taxonomy, $args ); $csv_rows = array(); if ( !empty( $terms ) ) { $csv_row = array(); $csv_row[] = 'cat_id'; $csv_row[] = 'cat_name'; $csv_row[] = 'cat_slug'; $csv_row[] = 'cat_posttype'; $csv_row[] = 'cat_parent'; $csv_row[] = 'cat_schema'; // WPML $is_wpml = geodir_wpml_is_taxonomy_translated( $taxonomy ); if ($is_wpml) { $csv_row[] = 'cat_language'; $csv_row[] = 'cat_id_original'; } // WPML $csv_row[] = 'cat_description'; $csv_row[] = 'cat_top_description'; $csv_row[] = 'cat_image'; $csv_row[] = 'cat_icon'; $csv_rows[] = $csv_row; foreach ( $terms as $term ) { $cat_icon = geodir_get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type ); $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; $cat_image = geodir_get_default_catimage( $term->term_id, $post_type ); $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; $cat_parent = ''; if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) { $parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy ); $cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : ''; } $csv_row = array(); $csv_row[] = $term->term_id; $csv_row[] = $term->name; $csv_row[] = $term->slug; $csv_row[] = $post_type; $csv_row[] = $cat_parent; $csv_row[] = geodir_get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); // WPML if ($is_wpml) { $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); } // WPML $csv_row[] = $term->description; $csv_row[] = geodir_get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type ); $csv_row[] = $cat_image; $csv_row[] = $cat_icon; $csv_rows[] = $csv_row; } } return $csv_rows; }