Displaying terms from Taxonomies in Poi List.

Home Forums MapPress Support Displaying terms from Taxonomies in Poi List.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #14245
    notmadein
    Participant

    Hello Chris,

    I would like to display in the list of pois under the map, the terms from two taxonomies. I browsed the forum and found no answer. I can display custom fields and that’s all. Can you help me?

    #14251
    Chris
    Keymaster

    Hi,

    Sure, I assume you’re using a mashup map? If so you just need to get the underlying post ID from the POI, and then you can use standard WordPress functions to get the terms for each post.

    For example this should print the terms for each post from one taxonomy ‘mytaxonomy’:

    
    if ($poi->postid) {
      $terms = get_the_terms( $poi->postid, 'mytaxonomy' );
      if ( $terms && ! is_wp_error( $terms ) ) {
        foreach ( $terms as $term ) { 
    	  echo $term->name;
    	}
      }
    }
    

    If you need to get more info about each term (like its label) you can use the WordPress get_term() function on each term.

    There are some examples here that might help:
    http://codex.wordpress.org/Function_Reference/get_term
    http://codex.wordpress.org/Function_Reference/get_the_terms

    #14252
    notmadein
    Participant

    Thank you very much Chris, it works perfectly.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.