I have just found the solution.
I just miss to put a taxonomy name.
$cat = get_term_by( 'name', $cat_name, 'city' );
this works fine!
Thanks,
Related Posts:
- Display All Products by Category with WooCommerce
- Add a URL prefix to permalinks of one category of posts only
- Woocommerce get category image full size
- Add forward slash on categories url (serve one version of a url)
- Elegant way to add parent categories?
- Alphabetical Index Page
- adding custom fields to next and previous post link
- Categories Listing with “selected” category highlighted
- Assign parent category to all posts that are already assigned to child category
- Using same slug name for a page and category
- List Categories of the Parent Category of the Current Category
- If no posts in category display Form instead of not found
- Link each category to last post
- Auto add pages to category menu
- Removing the number in a category slug
- Getting WordPress custom taxonomy/category?
- Get term by slug in Gutenberg
- How to get post category title within the loop?
- If category is in parent category?
- Hide posts of a certain category unless logged in
- Show only first children level of current category?
- Problem displaying one post from each category
- How do I automatically put categories and their descriptions on a WP Page?
- Taxonomy filter all children
- RSS/XML of all Categories and/or Tags
- URL path for wordpress categories
- Limit a meta box to a specific category
- get_posts and multiple categories
- How do I get rid of “category” from my URL structure?
- Only one post is showing on category page, why?
- Have different permalinks based on category
- How do I output all category with custom field?
- Add /category/ to an author archive page
- Remove subcategory and category with some rules from permalink
- How can I edit the ‘Most Used’ tab in the categories meta-box to show another custom taxonomy?
- category pagination got broken suddenly
- How to remove specific categories from posts?
- wp_update_post is not updating category
- how to get full category path including parent and subcategories
- WordPress get from single.php back to the right category page
- Categories are not listing their respective products
- Include WooCommerce product to all child categories
- Two columns in homepage each with one category
- Pagination on category.php and tag.php not working
- WordPress link to post links to category (loop)
- How do I attach a page to a category similar to how we attach media to a post?
- Display all product tags associated with a specific product category
- How replace individual elements in the RSS feed with a single string
- Category url generate 404 error
- how to nest specific category thumbnails inside different containers
- Style a category from category list
- Adding a page summary to a specific page
- Adding a block with query in homepage
- Add a category on all archive category pages
- what file I need to create to work date archive links?
- Category List and Automatic jQuery classes
- How to add image for all posts associated to specified category?
- Show the current post’s category, without displaying parent category
- get all categories’ latest post in one query
- Categories show 404 error on multisite installation
- Show posts from category specified using a custom field
- get_the_category – display only a single category for a post (not all categories)
- display category with background color
- WooCommerce Product category can be shown with multiple related URLs
- Categories are not available AT ALL under Menus
- change image on single product page with js
- Filtering blog posts by category
- How to get all post categories without custom post type categories?
- Get Categories of multiple posts
- Show subcategories broken when WP/WC updates
- Display menu in category and sub category
- Displaying a Category on a WordPress Page
- Show alternative menu based on page template AND post category
- How to change category labels in different colors?
- Display some WordPress categories as random order
- Display Category yearly wise in wp
- Get all subcategories IDs from categorie or categorieIDs
- Redirect category archives to pages
- How to create a category loop on my blog (ACF Plugin)
- Using heirarchial tags or Custom taxonomies
- On main page, in each post, display image depending on post category
- WordPress categories hierachy issue
- Get posts base on category ratio of more then two categories
- Images appear in the header on all pages, but not category.php
- Change single.php template based on parent category
- WordPress and “pretty permalink”
- Custom file with special code of category widget
- Custom field picture instead of post thumbnail on category page
- New Category – custom taxonomy
- Using categories and pages in menus
- Gettind 404 not found wen click the view button for a given category custom post type portfolio
- list first post of Child Category on Category page
- Use get variable when rewritten url in wordpress
- Back to category link
- Custom Woocommerce Category view
- exclude category in loop.php
- Show thumbnails 1-12 of category x on any given page
- How to delete categories in WordPress
- Images as Categories
- Replace category titles inside RSS feed