my solution:
$catid='24'
$cats = get_category ($catid);
if ($cats)
{$category_link = $cats->slug;
if ( $parent = $cats->parent )
{
$category_link = get_category_parents($parent, false, "https://wordpress.stackexchange.com/", true) . $category_link;
}
}
Related Posts:
- How do I use the same post slug for different Categories?
- Category links suddenly started giving 404 errors
- Plural Category Base Slug On Category Archive Page
- Duplicate Category and Page URL loads Category instead of the Page
- Displaying a full post instead of a slug per category?
- wordpress sub-category ( lowercase letters + non-latin characters ) = 404
- The default code for “posts_nav_link” on category.php isn’t working
- Mod_Rewrite to show only last subcategory in URL
- Older entries link within category page
- Use the category name instead of category slug in permalinks
- A different permalink structure for different categories
- How to remove category name for only one category?
- Include a page’s “category” in its URL
- hierarchical taxonomy in permalinks? using same slug
- How to add custom prefix before category base for category page URL?
- Custom permalink structure leads to be 404 on pagination
- How to get permalinks with category base working with sub-categories
- Filtering categories in the permalink structure
- Multiple post categories – single permalink
- How to exclude uncategorized from permalink structure /%category%/%postname%/
- How to get the url to tag & category base set by the user?
- Categories’ hierarchy in URL
- How to Include the Parent and Child Category in the Permalink if the Post is Added to Both
- Best and Cleanest way to remove /category/ from category permalinks? [duplicate]
- Root level category, tag, author and archive pages to work
- Divi change project slug based on category
- Archive pagination causing 404 with permalinks structure
- WooCommerce change category url and product base
- Category slug $_SERVER[‘REQUEST_URI’];
- 403 forbidden on one page only
- Allow dot in wordpress permalinks (only for categories)
- Using a portfolio_category slug in wordpress URL
- How to get category URL with the slug?
- Categories vs. Page Site Organization
- force category base – archive pages work WITH & WITHOUT category base slug in url?
- How get permalink for the current category or tag?
- Add “page-a” slug to category link if user visit category link from “page-a”
- Changing permalink from /postname/ to category/postname/
- Pagination for category slug returns 404 when page >= 2
- Class active for Archive link – looped out
- One Specific Category To Permalink
- Get category url in loop
- Sub Categories Keep Redirecting to Pages With Same Slugs
- Removing subcategories from permalinks [duplicate]
- Style category link depending on category ID
- How can you change the permalink for pages?
- Get posts from specific taxonomy term
- Get category URL knowing it’s id
- how to get full category path including parent and subcategories
- How to get Next/previous_post_link to go through articles in top parent category
- Hide the word ‘category’ from my permalinks
- How do I add a tag slug to a category URL to filter posts?
- How to Link to Most Recent Custom Post of Same Term
- Category url generate 404 error
- How to remove one specific category (uncategorized) from post permalinks
- Custom Permalink with child categories creating 404
- How do I retrieve the category ID (ugly permalinks) in my sub-navigation menu?
- Link from navbar to categories
- Redirect year month day postname permalink structure to category postname structure
- How to remove the category from post slug
- javascripts files not linking to my category slugs?
- url for posts for a date within a category
- wp_insert_link not working
- Categories show 404 error on multisite installation
- Need help with major category and permalink re-organization
- How to use category slug with a regular page
- Different post slug based on archive
- Allow two posts (from different categories) to have the same slug
- How Can I Use Equal And Question Mark In Category Slug?
- Subcategories randomly not working after page/post/category edit in wordpress. Fix: saving permalinks twice
- How to prevent WordPress from redirecting single page to prefixed category archive with same name?
- Is it possible to set up blog categories without changing permalink structure
- Remove WP Core canonical for category pagination
- How to 301 redirect from url with post id to permalink with post name (slug)?
- Subcategory Page 404ing
- Remove “category” from permalink with add_rewrite_rule
- Change the full slug for a specific category?
- Get category from slug list
- When category name and title are the same … WP will select archive.php instead of single.php
- Accessible Subcategory URL’s pages without using .php hack
- WordPress and “pretty permalink”
- How to auto update post title and slug with category name when post status is updated
- Hide category name using mod_rewrite
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- Group Posts by First Letter of Title categories
- Using categories and pages in menus
- Change category base based on category
- Possible to hide parts of the slug from get_template_directory_uri and bloginfo(‘template_directory’)
- Allow duplicate permalink slugs for posts in different categories
- Changing Permalinks for Category Pages Only
- Link categories to last post
- How to include first assigned category in the post URL?
- How do I hide posts in a category from all listings but still allow the posts to be viewed?
- Categories as selectable links on submission form
- Displaying categories and subcategories without link
- Custom permalinks structure
- Category archive page has two URLs even when default theme is active with no active plugins
- Custom EndPoint not working when strip child category in URL
- how to add permalink/slug to wordpress custom link menu item
- WordPress how to remove parent slug from category URLs