Ok guys found the solution myself (5 days later, oof) added below to help someone else in the future…
foreach((get_the_category( $related_post->ID )) as $category) {
$output .= "<a class=\"$category->slug\" href=\"".get_permalink( $related_post->ID )."\" title=\"" . $category->cat_name . "\">" . $category->cat_name . "</a>";
}
Basically the old link above looked like this…
$output .= "<a href=\"".get_permalink( $related_post->ID )."\">".$related_post->post_title."</a>";
I took the link and added it in a foreach
loop of it’s own. Then I prepared the foundations by calling the get_the_category for the related_post by it’s ID. That then gave me access to everything that the $category hook in WP offer, so I then simply call $category->cat_name for the category name and in turn $category->slug for the category slug name.
How cool is WP, VERY COOL!!! Anyway hope this help somebody out there.
Related Posts:
- Remove Slug from Custom Post Type results in 404
- Remove POST_TYPE from custom post type permalink
- Create a custom php page and load it at a specific slug
- Can I override the permalink/slug on creation
- Can a custom post type have a Parent Page?
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- Best way to flush_rewrite_rules for custom post type, in a mu-plugins plugin?
- How do I append multiple taxonomies to the URL?
- Custom Post type & Taxonomy URL structure
- Multiple post types – share same ReWrite slug?
- Slug Formatting : Acceptable Characters?
- Disable permalink on custom post type
- Combining Multiple Taxonomies in one URL
- Change slug of registered custom post type in child theme
- Redirect after deleting post and keep track of pagination
- Dynamic taxonomy in permalink made all other posts NOT FOUND?
- How to achieve this permalink -> category-name/custom-post-type-name/post-name
- Prepend meta_value to permalink of post
- On clicking on the category name the page is redirecting on 404 pge
- Remove taxonomy slug when not assigning taxonomy with custom post types
- Interesting Custom Post Type Slug with Taxonomy and Custom Field
- Can’t edit Custom Post Type slug/permalink
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- Remove Taxonomy Slug when No Taxonomy is Assigned to Custom Post Type?
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- Custom Taxonomy breaking pages permalinks
- Programmatically adding posts
- Extend the wp_get_archives output with ‘?post_type=foo’?
- removing custom tax & CPT slug, adding taxonomy term in front of custom type
- Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure
- Customize permalink when creating a post
- Custom Post Type | Fatal Error on register_post_type()
- Automaticly add slug to posts
- How do I fix permalinks for custom post types that has the same slug as a page?
- Get rewrite slug of custom post type in template
- Why does wordpress keep adding postname to my CPT’s permalink in the end?
- Wrong generated page_name/slug on first publish of custom post type
- Remove post type slug of all post types from permalinks
- Stop / prevent WordPress from updating permalinks of custom post type
- How to customize a permalink (URL) structure?
- Plugin: register custom post types, child ready and performance best practices
- Permalink structure by Post Meta value
- Child post with numeric only slug keeps redirecting to parent
- Permalink for a custom post type isn’t working and I don’t know why
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- Assign same parrent Page to pages AND custom post types
- Custom Permalink to remove category word , keeping posts permalink with date?
- How to include term custom meta into the custom taxonomy term permalink structure
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Custom Post Type – Duplicate Page Slugs
- Redirect to another page using contact form 7? [closed]
- Remove permalink for custom post type
- How do you create %post_type%/%postname%/ permalink structure?
- How to insert data into meta box from another plugin?
- Custom Post Type Advanced Slug
- Custom Post Type to replace Woocommerce products – page not found error
- Custom Post Types and Removing Slugs – should we do it?
- Convert Custom Table Data Based Plugin To Be Searchable
- Need to return a string as permalink insted of str_replace
- Under What Conditions Can I name my CPT the same as my CPT Page?
- Custom rewrite rules for /pastissues/%category%-%postname%.html
- Is it possible to have hierarchical taxonomy and hierarchical custom post types in one permalink?
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- WP 3.1 custom post type permlinks
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- Custom Endpoint For Specific Custom Post Type
- Error 404 change permalink term custom term taxonomy
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- custom post type and user post count shortcode
- Changing CPT permalink
- Custom post type defaults to index.php for archive page
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Change permalink incrementor into pseudo-subdirectory
- % encoded URL giving 404 error in WordPress
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Two CPT: one is using part of the custom rewrite slug from the other
- WordPress page not showing up – replaced with last 10 posts?
- Custom permalink rewrite rules – how do I fix this?
- Problem to get the link of the default ‘post’ post type like the orther custom types
- Registering an optional custom post type from a plugin
- Get full control over custom post type url
- Remove Custom Taxonomy Slug only without removing Custom post type slug in permalinks
- Can’t make permalink of CPT work
- How to make nested custom post type slugs work
- Add Excerpt On Quicksand Plugin
- Multiple Block Quotes without using HTML
- How to apply order on custom taxonomy and custom meta key on custom post type
- Set a Custom Post Type as a Homepage
- Hide custom post type slug url from search engine [closed]
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- Custom post type Premalinks main page and details page
- How to change permalink structure off default posts and also CPT’s posts
- Remove unwanted part of permalink custom structure from CPT url?
- Changing a custom post type “has_archive” after registered
- Custom Post Type pagination when CPT ‘rewrite’ rule and a page have the same slug
- dynamically update permalink and title with the values of custom fileds
- Getting meta in editor plugin, and event triggering issue
- How to add attributes to taxonomies that may be different from post to post?
- Not Able to Add New Class To CPT Attachment Image
- Category / Custom Post Type permalink issue