The problem, as I could see it, is not with the get_the_category()
function. Instead, it’s the way you output the category archive link: href="<?php echo $cd->slug ?>"
— you should instead use get_category_link()
to get the correct URL of the category archive page. Example:
<a href="<?php echo esc_url( get_category_link( $cd ) ); ?>">
Related Posts:
- Difference between the_permalink() and get_permalink() function
- Display random categories on the front page (Finding and Editing Theme Functions)
- Use author author display name in permalink structure for pages and posts
- paginate_links() don’t properly work in search.php?
- Refresh page after form action
- How to add classes to images based on their categories?
- current_cat_ancestor Alternatives
- Add body class of category parent
- Convert hyphen to underscore in permalinks
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Php string not working in WordPress Functions.php (trying to fetch 1st category for each blog that post appears in the sidebar)
- Add class to Categories Widget
- How to Acheive the custom woocommerce category template
- How to add a rel attribute to images that contains their categories?
- How to set child post categories to parent post categories when updating parent post?
- Assign category using custom field?
- How To Get WordPress Categories Link List?
- Adjust which tempalte a page uses with a function?
- Generate permalinks
- Changing post category from dropdown
- Manipulate Output of wp_list_something: select menu instead of li’s
- Disable shortlinks like ?p=1234 to prevent scraping
- Make Categories a Dropdown Menu in Media Library
- Programmatically Create Category and sub Category
- Attach parent category template to all subcategories
- exclude a category from a search on a specific page
- Get the category name outside of the loop in category.php
- Is it possible to change any of the HTML/URL returned from the_category()
- Manipulate Permalink
- Custom HTML in specific category single page and its descendant categories
- Possible to display shortcode based on the category?
- Unset Category if other Category is unset during post transition
- Select pages by category
- Show Primary Category first when I display post categories
- How do I hide or remove ‘Category’ from wordpress breadcrumbs
- Ordering posts by publish date not working?
- Customize permalink wordpress category id
- Categories as main menu items and subcategories as nested lists
- How to get correct URLs in network wide menu (Multisite)?
- Where to add the permalink in this function?
- paginate_links() don’t properly work in search.php?
- Get category URL for current post
- Need help “sanitizing” a custom function that pulls category slug into body class
- allow only one post in specific category
- How to obtain the recent posts without their content in an efficient way?
- Setting a default text for excerpts of a particular category
- Running script based on Category
- Remove a category from a post when saving a new post
- Return category name with & Ampersand doesnt work
- Test if a post exists by category and date
- Access category within rss2_head hook?
- issue with if/elseif in_array inside foreach loop display only one post
- Randomizing wp_tag_cloud() in child theme
- add_filter to specific WooCommerce Category
- How to rewrite wordpress search to work on specific category
- How to properly refresh page after form action?
- Image loading function not working on archive.php template
- Exclude Category ID in function
- Problem with calling custom function in a foreach loop
- Specify multiple categories for custom post template – FATAL ERROR
- “All posts” in the category widget
- Setting Permalinks in wp_config or functions file?
- Get Attachment Category Name
- Redirect to post after publish or update a published post
- WordPress Categories: Function using custom SQL to return array of specific category IDs
- Display ACF category image on archive and single template files
- Get slug of current category in functions.php
- Display a list of random terms from custom taxonomy with shortcode
- How to add extra value to permalink
- Change category display name function
- Display link to category over featured image
- How Can I Create a Friendly Slug for a Dynamic Page?
- Add #primary at the end of navlink permalinks on single posts
- Remove the ‘category’ url for one category type
- Custom Function.PHP Code Not Working on One Site
- Adding new Category does not refresh the backoffice
- How do i tweak my wp Post title base on category of the post
- how to remove a tag in the_category function
- Menu and category highlighting for a single post
- i can’t use wordpress functions in ajax loaded php file
- Graphic before title – Specific Category
- Filter posts on new page
- require_once() Causing categories and tag pages on dashboard to not refrsh
- different body classes for each category
- How To Get WordPress Categories Last Update Date?
- Check if excerpt is empty at loop-portfolio
- Exclude javascript in certain page url and all following url’s after forward slash
- How to get tags and categories?
- How to Insert A List of Posts in A Category Written by the Author into the Author Archive
- Removing all Category pages with one exception
- Get category of post inside save_post hook
- I am looking for a function to create category links in the wordpress loop for articles
- How to get the proper category in permalink with custom post type assigned to multiple categories
- Override categories with Pages (block theme)
- Is it possible to go to the next post in the same category?
- Custom permalink for post of one category
- Hreflang Tags from the Most Recent Post Appearing in Category Page Headers
- How to Programmatically Replace Characters in WooCommerce Product Slugs?
- Accessing two databases wordpress
- Add a jQuery Function