This is probably not the template for a category archive, but for a custom page template because of this:
/*
Template Name: Categories
*/
The query variable ‘cat’ is not set in pages.
Move get_category_link( $id );
inside the foreach.
<li><a href="https://wordpress.stackexchange.com/questions/151716/<?php echo esc_url( get_category_link( $cat->term_id ) ); ?>"><?php echo $cat->name; ?></a></li>
Related Posts:
- Get the name an the description of a link category
- How to get category URL with the slug?
- Linking products to categories
- force category base – archive pages work WITH & WITHOUT category base slug in url?
- How do I get rid of “category” from my URL structure?
- Place category Base URL at the end
- How to display post type and category links in foreach WordPress code
- Why is it so hard to show the URL of the current category and how to do it?
- Latest updated categories list query, exclude one from displaying
- wp_insert_link not working
- separate posts to have (kind of) 2 blogs?
- How can I display a list of categories of my posts
- can I ‘combine’ categories as a menu item?
- Show parent category wp_list_categories wordpress
- Showing the category hierarchy as clicked in WordPress, with image and desc
- Linking to the most recent post in my podcast category
- echo $category[0]-> cat_name; shows only one category name
- Creating a linkable category list with post count
- Custom EndPoint not working when strip child category in URL
- How would I get a taxonomy/category list inside a Gutenberg block?
- Rewrite rule page url with category
- WP_Query not looking at child category
- Deleting default category in wordpress
- Excluding posts from a category but only if they’re not in multiple categories
- Most recent post from every category/taxonomy but sorted by date
- Showing all the posts in one page?
- How to order categories in Woocommerce that are spread over multiple pages? [closed]
- Script to duplicate categories as tags
- Check if post belongs to any category
- How to sort categories by id in wordpress admin
- How to override Category rendering mechanism
- Automatically add product_categories to nav_menu
- Can paginate_links() be customized for a specific category or tag?
- Add Product categories to WordPress menu without losing hierarchy
- How to set up Author archives with sub category URL
- How to change number of items on add new pluggins page from backend?
- Ignoring a category in WP_Query still shows the links in next_post_link()?
- Implementing a tricky wordpress menu (nested categories + thumbnails)
- Do I have to use categories?
- get_the_category and echo out link to child-most/deepest category
- Categorising posts/pages into years published
- How can I duplicate categories and tags?
- Display category description instead of “nothing found” page
- Subcategories with the same name
- Removing post category base giving Error 404
- posts_nav_link(); picks up index.php instead of category.php as template
- Category name field strips HTML tags. How can I reverse this?
- Check IF category_description exists
- Related Tags not in category
- How to get the last category name of a child category?
- How to show a list of only categories (exclude subcategories)
- How to list categories in reverse alphabetical order?
- I want to show category name when using [category] shortcode
- Category list with postcount
- What Must to Display the “mysite.com/category” URL?
- How to hide some categories in dashboard
- How to choose the content from a post which is in the right category?
- How to display product with two condition, category and brand taxonomy
- How to get category id’s which are added in main menu?
- List all posts of certain category which share some tags
- Search form options group categories
- Natural sort / ordering wp_dropdown_categories
- Make wp_dropdown_categories into a variable that persists until changed?
- show category in woocommerce
- Can I define multiple paginations on a single page?
- Echo Category Nicename
- Category sticky latest
- How can I exclude a category from the main loop with the category name & not ID?
- Explode() expects a string
- How to add meta description, keywords, custom title to a category template
- how to remove alphabetical order of category in WordPress?
- How can i add service category here? [duplicate]
- How to exit out of delete_categories and stop action?
- Meta Query | Compare category name and meta value
- How to filter tags by category?
- Programmatically Create Category and sub Category and sub sub Category
- How Can I Display the Category Description in a Theme with no Category.php or Archive.php?
- WooCommerce – Get products from category right before deleting category
- omit categories from main navigation menu
- How to test if the post is in a primary category
- How to get the term id inside the start lvl method of category walker?
- Most efficient way to display current post subcategories?
- How to relocate images
- Category next page link not working
- How to display the past events in one of the category?
- How to Query the Top 5 Posts of a specific category?
- How to add a post with new Taxonomy without assigning to default category?
- Page Type with Category Link
- Using wp_list_pages to create 2 lists of pages and include and exclude some of them depending on their category
- How to create default categories in new installs?
- If I change the taxonomy of a post will it get a new time stamp?
- Check if value is a custom taxonomy category name
- Tracking multiple tags or categories
- 2 loops in archive.php (one for each category)
- How to load jquery tag-it plugin into admin?
- not empty categories don’t show in menu [closed]
- How do I add and display a custom image field to a category? [duplicate]
- Category pagination not working in category.php please help me
- Print the associated categories of the current post starting with parent (with option to remove href)
- Add category image before post title on homepage