You are fetching all the terms of your taxonomy, Use this instead :
$terms = wp_get_post_terms(get_the_ID(), 'city-type');
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
echo '<span>' . $term->name . '</span>';
}
}
Note : First argument to the function is id of the post, get_the_ID() will work fine on single post details page and within loops. Function reference on WordPress
Related Posts:
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Group posts that matches a term in a loop
- How to handle “the_terms” inside loop
- Generic taxonomy-term template page
- Operations with custom fields values in a loop
- Display all posts that use a custom taxonomy
- How can I reduce amount of ifs and else ifs in this specific block of code?
- List terms of custom taxonomy if matches other taxonomy
- How to get the term description in a taxonomy term archive query?
- How to use custom slug and custom templates for custom taxonomy?
- How to add a shortcode function that returns the taxonomy slug of the actual post within the loop
- How to get a terms and posts associated with another term?
- Output slugs to use as class names for every taxonomy a post is attached to
- Query pages by child term
- get_the_term_list without links in 3.1
- Inserting terms in an Hierarchical Taxonomy
- get_term_children for immediate children only (not grandchildren)
- Can’t get a custom template taxonomy page to display
- Display category posts grouped by taxonomy
- Custom Taxonomy Archive Page
- Is there a way to ‘Lock’ a Taxonomy?
- Creating a non-removable taxonomy term
- Return only the custom sub-term for custom post type, do not echo term-parent
- wp_insert_term is adding a term that has no name
- Display one post from each term in a custom taxonomy [closed]
- Get terms from multiple taxonomies
- Formating the_terms() function output
- get_terms showing link to category even if all posts are drafts
- Retrieving custom taxonomy in order, but excluding specific tax IDs
- Is it possible to sort the post based on a custom field?
- get taxonomy terms for parent and child
- On Taxonomy Template page, want to add Post_Type
- Taxonomy query for children of parents
- Separator for multiple terms
- Contact Form 7 – Populating dropdown list with terms relative to the post
- How to create a theme template for the taxonomy “root”
- Checking if a Page has an Associated Term?
- What are terms and taxonomy, how they related to post and how these three are stored in database?
- Get multiple term objects by ids
- Echo custom taxonomy term name
- How to create drop down for child categories of current taxonomy being viewed?
- How to dynamically add custom taxonomy terms as a sub-menu of an existing menu item, using custom walker class
- Why does WP rename similar “term name”-slugs in separate taxonomies?
- Get Bottom Most Level Taxonomy Terms?
- How can I get WP to build a feed based on multiple taxonomy terms
- get_terms in a taxonomy template
- Set custom post type terms by id without knowing taxonomy
- Display hierarchical subterms of custom taxonomy based on depth
- How to determine the depth of a term in a custom taxonomy?
- How do I Use Multiple Loops with WP_Query?
- How to adjust code to refresh a dropdown box with tags that are active on filtered category listing
- get_term_children doesn’t return an array of children terms
- How do I display a list of posts under all hierarchical children of the current taxonomy?
- Use get_the_terms to list subcategories of custom taxonomy
- Term count by user
- How to add contents of a custom field to a taxonomy term list?
- Updating / Saving items generated by wp_terms_checklist on frontend
- Rewrite rules for varying nested terms of custom taxonomy
- List Posts For Terms Of A Custom Taxonomy For Any Post Type
- Query posts from a child taxonomy term id
- get_terms() duplicate first term of a custom taxonomy
- Update table wp_term_taxonomy.count after INSERT INTO via SQL
- Exclude taxonomy term from all loops, but having it on widget
- Get all attachments by custom taxonomy – term
- Get terms that don’t belong to current post with a shortcode
- How to get posts that contain multiple terms from multiple taxonomies?
- Cannot delete or edit a single term in a custom taxonomy, taxonomy name is wrong?
- How best to store data (URLs and IDs) extracted from posts and pages using custom taxonomies
- Get name of taxonomies of current page
- Create alphabetical Pagination for custom taxonomy?
- pagination not working on custom-taxonomy template
- export and import taxonomy terms from one taxonomy to another
- URL rewriting taxonomy term
- Find terms in a custom taxonomy based on the hirearchy
- Wp_query…a type of term a different div
- How to break up php code to avoid echo
- Show all terms in a custom taxonomy with all child terms wrapped in a ul
- Order taxonomy terms wordpress
- Show single Child Category on Custom Post
- Only display latest custom taxonomy post
- How to loop custom posts that have an exact match in taxonomy terms?
- wp_insert_post not adding taxonomy (using wp_set_object_terms)
- Filter “get_terms” query
- posts_per_page is not working by term
- ACF – Get unique values of array
- Remove Custom metabox from particular page template is used
- generate random slug when adding taxonomy
- Add active class to foundation 6 tabs while looping categories
- How to filter a taxonomy meta field to the ‘single_term_title’ filter hook
- Custom post type term names with ampersand in the term name
- If page is a taxonomy do X, if is a term, do Y
- Getting the parent terms adds additional empty markup [closed]
- Custom taxonomy list in two columns
- How to display custom taxonomy and terms using/creating plugin template
- Insert term description programmatically into hierarchical custom taxonomy
- get multiple values from $_GET from multiple checkboxes
- Get post terms with hierarchical relationships
- Taxonomy archive link from term id
- How home my code doesn’t display any feature image? Looping through post from a taxonomy and not getting feature images back
- How do I check if a post has a term with a particular ancestor/parent?