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
- How do I exclude a custom taxonomy from the post loop
- get_posts assigned to a specific custom taxonomy term, and not the term’s children
- How can I get only parent terms?
- Retrieve posts by term id custom query
- Change order of Custom Taxonomy List
- Get the the top-level parent of a custom taxonomy term
- get_the_term_list without links in 3.1
- Inserting terms in an Hierarchical Taxonomy
- get_terms – only top level
- How to only list the child terms of a taxonomy and not their parents?
- Hierarchical taxonomy UI
- How to prevent new terms being added to a custom taxonomy?
- Order get_terms using a Custom Field
- Show posts without term
- get_term_children for immediate children only (not grandchildren)
- Can’t get a custom template taxonomy page to display
- Query users by custom taxonomy and user role
- Display category posts grouped by taxonomy
- Custom Taxonomy Archive Page
- Determine Term depth
- How to get current term in my custom taxonomy in WordPress?
- Is there a way to ‘Lock’ a Taxonomy?
- Hide the term description on the term edit page, for a given taxonomy
- Order terms by term_order
- get_term_by not working when in functions.php
- Creating a non-removable taxonomy term
- display posts with same taxonomy term
- Get value in custom field with taxonomy [closed]
- Get second level terms of custom taxonomy
- Can I lock down custom taxonomies on a parent term level, but not a child term?
- Including all terms in wordpress tax_query
- Get only the first term by taxonomy
- Taxonomy Templates… by hierarchical level?
- Exclude specific slug in ‘get_terms’
- Large taxonomy (2000+ terms), causing WordPress to hang
- Custom order of terms for custom taxonomy in admin and website
- Is there a way to disable a term rather than deleting it?
- How to display a listing template of a certain taxonomy?
- Modify Term Update Redirection
- Best pratice to make taxonomy terms translatable without changing slugs?
- Front End Post Save Child terms
- 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
- Taxonomy slug by term ID
- Display one post from each term in a custom taxonomy [closed]
- Check if current term is a child of another term
- Is there a way to import terms into WordPress?
- get_terms() doesn’t return empty terms even though hide_empty is false
- Get terms from multiple taxonomies
- How to use wp_terms_checklist() on front end
- Get taxonomy name of current post
- Formating the_terms() function output
- Custom taxonomies, with custom rewrites/slug, AND loading a taxonomy archive template from a plugin
- get_terms() returns an empty array
- wp_insert_term auto unique name
- get_terms showing link to category even if all posts are drafts
- Determine if Term has Grandparent/Great-Grandparent
- Custom Taxonomy Template not respecting ‘include_children’ => ‘false’
- Custom Taxonomy Only Showing Top Level Terms in Admin?
- Dropdown: Display terms from B only if has relationship with a term A selected
- How can I set up a category “overview” page?
- Non-hierarchical custom taxonomy using checkboxes on edit-screen -> saving issue
- Retrieving custom taxonomy in order, but excluding specific tax IDs
- wp_get_object_terms – How can I order the resulting array by hierarchy?
- Get main parent categories for a product
- Get current term’s ID
- Custom Post Type Archive Template
- Is it possible to get a Previous/Next Taxonomy term archive URL?
- Which template name to use for taxonomies but not their terms?
- Is it possible to sort the post based on a custom field?
- Showing posts by collection of specific terms and texonomy
- get taxonomy terms for parent and child
- On Taxonomy Template page, want to add Post_Type
- Taxonomy query for children of parents
- show term description instead of list terms of custom taxonomy
- WP_insert_term how to insert multiple values as taxonomny term?
- Custom taxonomy template loop
- term_link() filter or rewrite and howto?
- How to get the top most term (top ancestor) of a custom taxonomy child term?
- Display Custom Taxonomy Terns ordered by meta_value
- Separator for multiple terms
- Contact Form 7 – Populating dropdown list with terms relative to the post
- Custom Taxonomy terms with latest post ordered by date pagination issue
- How to set hierarchical terms to a post using wp_set_object_terms
- Echo taxonomy term meta on author.php
- get_the_term_list without specific category