Get the name of the selected custom taxonomy


/ Published in: PHP
Save to your folder(s)

Use this to get the name of the custom taxonomy. Note that this only returns the name of the first selected item, but since this returns an array, use a foreach loop to find all names.


Copy this code and paste it in your HTML
  1. // get name of manufacturer of this post
  2. // replace 'manufacturer' with the id name of your custom taxomony
  3. $manufacturer = wp_get_post_terms($post->ID, 'manufacturer');
  4. $manufacturer_name = $manufacturer[0]->name;
  5.  
  6. // use this to display the name
  7. echo $manufacturer_name;

URL: www.centerdrive.ca

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.