Retun Taxonomy Terms
-
Hi,
I am using a bones theme with the following setup:
1. Custom taxonomy as below:
add_action( 'init', 'register_taxonomy_provinces', 0 ); function register_taxonomy_provinces() { $labels = array( 'name' => _x( 'Provinces', 'provinces' ), 'singular_name' => _x( 'Province', 'province' ), 'search_items' => _x( 'Search Provinces', 'provinces' ), 'popular_items' => _x( 'Popular Provinces', 'provinces' ), 'all_items' => _x( 'All Provinces', 'provinces' ), 'parent_item' => _x( 'Parent Province', 'provinces' ), 'parent_item_colon' => _x( 'Parent Province:', 'provinces' ), 'edit_item' => _x( 'Edit Province', 'provinces' ), 'update_item' => _x( 'Update Province', 'provinces' ), 'add_new_item' => _x( 'Add New Province', 'provinces' ), 'new_item_name' => _x( 'New Province', 'provinces' ), 'separate_items_with_commas' => _x( 'Separate provinces with commas', 'provinces' ), 'add_or_remove_items' => _x( 'Add or remove Provinces', 'provinces' ), 'choose_from_most_used' => _x( 'Choose from most used Provinces', 'provinces' ), 'menu_name' => _x( 'Provinces', 'provinces' ), ); $args = array( 'labels' => $labels, 'public' => true, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_tagcloud' => true, 'hierarchical' => false, 'rewrite' => true, 'query_var' => true ); register_taxonomy( 'provinces', array('add_listing'), $args ); }
2. My call back function in the php loop (template)
<?php // Display label echo "Province/s: " . $provinces; // Get the taxonomy province by post id (dynamic) $myterms = get_term( $post->ID, 'provinces' ); print_r($myterms); //echo ($myterms); echo "ERROR!"; ?>
The only thing that displays in that case is the “ERROR!” output.
Err, what am I doing wrong?
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Retun Taxonomy Terms’ is closed to new replies.