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?
- Remove parent category from permalink? Basically only have the child category?
- Use category base slug in posts’ permalink
- Category archive by year with permalink support /category/YYYY
- Add a URL prefix to permalinks of one category of posts only
- Force WordPress to Show Pages Instead of Category
- How do I get the category URL from get_the_category?
- Rewrite rule page url with category
- How to control which category will be picked for the slug of a post?
- Create terms when registering taxonomy?
- Changing the category permalink structure
- Using same slug name for a page and category
- Add category to custom post type automatically, using category slug
- Exclude subcategories from the url
- I use same slug name for category and page
- Removing the number in a category slug
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Permalinks – Different structures for different categories?
- Return category slug / title from category ID
- Removing category base form links messes up the parent-child behavior
- Put a link to a category round a hard coded A HREF
- New categories are now going to 404s
- Best way to programmatically link to multiple categories (union/intersection) [closed]
- Default category link for a custom category is a broken link
- How to set up Author archives with sub category URL
- How to filter posts by format and category via url?
- How to Filter categories in the permalink structure
- Possible to make a subdirectory that loops through a single category?
- How to enable category hierarchy for links?
- Need to pull parent category and slug – only pulling daughter category
- Combining post categories and link categories?
- Link Attachment Image to Category
- Why do my categories redirect?
- Category being displayed without base parmalink
- Removing post category base giving Error 404
- Categories showing page not found
- Read GET parameters in APACHE Mod Rewrite rules for WordPress categories in Posts
- Have different permalinks based on category
- Same base for category and post
- category permalinks
- Hide uncategorized when no category set
- Remove subcategory and category with some rules from permalink
- WordPress URL Rewrite for dynamic and customized URL
- 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 add a post without assigning to a category?
- How to get Next/previous_post_link to go through articles in top parent category
- 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
- How do I retrieve the category ID (ugly permalinks) in my sub-navigation menu?
- Link from navbar to categories
- How to remove the category from post slug
- url for posts for a date within a category
- wp_insert_link not working
- Categories show 404 error on multisite installation
- 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?
- 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
- Subcategory Page 404ing
- Change the full slug for a specific category?
- 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
- Group Posts by First Letter of Title categories
- Using categories and pages in menus
- 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
- Use same wordpress category base and tags as the prefix as the post permalink
- Custom post type Premalinks main page and details page
- How to change permalink structure off default posts and also CPT’s posts
- How to remove the category from the url only for a specific category of articles on wordpress