This is happening because the_category()
outputs a list of categories, with links. So it’s outputting its own <a>
tags, and you cannot put <a>
tags inside other <a>
tags. It’s not valid HTML.
What you’re seeing is the browser’s attempt to produce valid HTML based on invalid markup. HTML is very resilient, and invalid markup will not cause it to crash. THe browser just does things like this. If you look at the raw HTML returned for the page in the Network tabs of the browser’s developer tools you will see what HTML your template actually created.
If you want to output the list of a post’s categories without links, you will need to do something like this:
Related Posts:
- What is the difference between get_post_permalink and get_permalink?
- WordPress matching URLs with trailing tildes
- Rewrite Rule for Multilingual Website, Like qTranslate?
- How to use relative links on my pages?
- How to filter to output of the get_permalink() function
- Change slug on post creation
- WordPress Permalink changes to question mark (?) in URL
- Is there a user-facing interface to edit an attachment’s permalink?
- Can WordPress realistically handle a site with 500 ‘pages’?
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- WordPress on a subdirectory of Laravel – WordPress pretty permalinks inner page shows laravel
- Get post title with link
- WooCommerce permalinks [closed]
- Menu Link Redirect Based on Username or User ID
- Redirect short-form URL to long-form URL (post_id to post_id + post_name)
- Enable Minify in W3Total Cache using NGINX [closed]
- Can’t change permalink url after hitting ‘ok’ and ‘update’
- Rewrite user profile URL to be human friendly
- Why I can’t change the permalink of this page?
- Sub-category and category in permalink structure
- Permalinks changed with WordPress 4.9
- Permalinks broken regularly
- 404 Page Not Found for Only One Post
- Call to a member function add_rule() on a non-object
- How to change Post ID during import
- How can I add a page’s ID to its permalink using WP_Rewrite?
- Debugging permalink issue
- WordPress 404 in development area
- Does rename of page slugs create 301 redirects from old slug to new (same as for posts)?
- Changing post content on save, using updated fields
- Change blog segment of URL
- Change in permalink structure made javascript cookie not work correctly
- why some permalinks adding characters/ruining links
- Multiple taxonomies on same permalink rule [closed]
- How to bulk edit image url in featured image and product description?
- WordPress category base not in post permalink
- What’s actually happening when permalinks for custom post types suddenly stop working
- Redirect a Blogger Page URL to wordpress
- Images in media library have suddenly disappeared
- Edit page slug after save, cause 404 by linked pages
- Conditional permalink structure
- Auto setup “permalink” or request notice
- How to add .html to the end of the permalink
- IIS 7 Rewrite with parent categories
- permalinks issue and archives
- get_permalink() always returns empty
- Press-This stopped redirecting to permalink after post publish
- Giving a new page an existing URL
- When do i need to get permalink structure of a specific post?
- implement separate templates for 1 post type
- encoded search terms with %20
- Permalinks not working on new site
- Adding URL prefix for foreign language support
- Custom links in menus not working in multiple environments
- Remove all stop words from old permalinks
- 404 error on all pages but custom post types are working OK
- using wp_redirect to redirect to a permalink
- old permalinks not found
- WordPress permalink from the database?
- How can I see a list of all pages my WordPress site has generated?
- Can I change the URL structure for a CPT only?
- Display parent page URL for child page
- How to set add_query_arg properly for home page?
- How to redirect old permalinks from https://exmaple.com/category/post_id to https://exmaple.com/category/post_id.html
- Double Slash After Media Path (uploads//)
- Make a post inaccessible without a unique ID in the URL
- Undefined variable: testimonial in D:\Projects\PWP-WP\wp-content\themes\blankslate-child\template-parts\fields\flex\bottom-page-block.php on line 123
- Is it possible to set public to false for the native WordPress blog
- Code snippet to add filter pre_post_link to change Media URL (post_type attachment permalink/slug)
- Change permalink structure in all sites of a multisite
- Changing permalink stops me from creating webpages
- Make query parameter an endpoint
- WP adding noopener and noreferrer to all links
- 301 redirects after changing permalinks
- Rename Custom Post Slug using taxonomy
- Link works although page was moved to another location
- Added a prefix in URL permalink structure but the old structure still working!
- Permalink of post redirect to uncategorized category
- Getting current page URL when default permalink is set
- create user’s view profile link with username
- The Permalink doesn’t work after the foreach ended
- Force/Limit the post/page slug to accept only url friendly characters
- Make Permalinks have a custom format?
- Permalinks setting raises 500.0 error
- permalinks of subcategory and posts
- Define a Permalink Structure by Post and Page
- After changing permalink settings, everything works fine except for the two most recent posts
- Installing WordPress in another Install?
- using post meta data as permalink tags [duplicate]
- How to display post permalinks instead of pages?
- permalink repeated
- .htaccess not working in WordPress
- Incorporate single WordPress page into an existing static website [duplicate]
- How to configure WordPress to be a subdirectory of my main site as mymainsite.com/blog?
- How to avoid duplicate Url for the home page
- Removing parent page in URL for one page
- Remove index.php from URL
- htaccess strip url
- Problems loading stylesheet and permalinks after rebooting
- Remove parent product category slug from product_cat url woocommerce