Accessing array from within a plguin…
-
Hey guys,
I have this code within my plugin:
add_action('init', 'my_country', 100); function my_country() { $country_array = array( 'AF'=>'AFGHANISTAN', 'AL'=>'ALBANIA', 'DZ'=>'ALGERIA', ....
I want to read the array from within the my template file but nothing happens. I actually want the key value and not necessarily the name:
This code doesn’t work:
if ( function_exists ('my_country') ) { my_country($country_array); // return stuff from the array... nothing happens ... }
but this works, however it does not return the array keys ??
$terms = get_the_terms($post->ID, 'my_country' ); if ($terms && ! is_wp_error($terms)) : $term_slugs_arr = array(); // old array foreach ($terms as $term) { $term_slugs_arr[] = $term->name; } $terms_slug_str = join( " ", $term_slugs_arr); endif;
What could I possibly be doing wrong!?
And the other thing… everytime I disable and enable the plugin, it duplicated the taxonomies in the database, e.g. Belgium-2, Belgium3, etc.
- The topic ‘Accessing array from within a plguin…’ is closed to new replies.