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?
- Disable Category Link
- Remove parent category from permalink? Basically only have the child category?
- Custom permalink structure leads to be 404 on pagination
- How to get permalinks with category base working with sub-categories
- 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
- Catch 404 after changing permalink structure from /%postname%/ to /%category%/%postname%/
- Filtering categories in the permalink structure
- Allow duplicate permalink slugs for posts in different categories
- 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 remove category from wordpress url?
- Multiple post categories – single permalink
- How to create a custom url for a category [closed]
- How to change the category in URL for posts in multiple categories?
- How to exclude uncategorized from permalink structure /%category%/%postname%/
- How to get the url to tag & category base set by the user?
- How to control which category will be picked for the slug of a post?
- Create terms when registering taxonomy?
- 404 error on subcategory pages
- Categories’ hierarchy in URL
- How to create non-unique sub-category slugs?
- Rewrite category slug
- Changing the category permalink structure
- How to Include the Parent and Child Category in the Permalink if the Post is Added to Both
- Using same slug name for a page and category
- Add category to custom post type automatically, using category slug
- Best and Cleanest way to remove /category/ from category permalinks? [duplicate]
- Exclude subcategories from the url
- How to display only the parent category in the permalink
- Root level category, tag, author and archive pages to work
- I use same slug name for category and page
- Divi change project slug based on category
- Removing the number in a category slug
- Categories and Tags returning 404 on the sidebar when using ugly permalinks
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Archive pagination causing 404 with permalinks structure
- Permalinks – Different structures for different categories?
- custom permalinks for category archive ( custom base and no parent slug )
- Return category slug / title from category ID
- WooCommerce change category url and product base
- 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
- Any way to assign Post Categories and Tags to Links?
- Best way to programmatically link to multiple categories (union/intersection) [closed]
- Default category link for a custom category is a broken link
- Category slug $_SERVER[‘REQUEST_URI’];
- 403 forbidden on one page only
- How to set up Author archives with sub category URL
- Allow dot in wordpress permalinks (only for categories)
- Get the name an the description of a link category
- Using a portfolio_category slug in wordpress URL
- wordpress wp_list_categories
- How to get category URL with the slug?
- Is it possible to select and edit the way the most recent post from a certain category is displayed on the page?
- Categories vs. Page Site Organization
- WooCommerce duplicate sub categories and product slugs
- How to filter posts by format and category via url?
- How to Filter categories in the permalink structure
- Specifying multiple categories in URL (permalink)?
- 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
- WordPress subcategories return 404 in custom template
- 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”
- Redirect category to url with /category
- Changing permalink from /postname/ to category/postname/
- Combining post categories and link categories?
- Pagination for category slug returns 404 when page >= 2
- Link Attachment Image to Category
- Class active for Archive link – looped out
- One Specific Category To Permalink
- Why do my categories redirect?
- Category being displayed without base parmalink
- Removing post category base giving Error 404
- Categories showing page not found
- How to disable default category linkbuilding?
- Read GET parameters in APACHE Mod Rewrite rules for WordPress categories in Posts
- Get category url in loop
- Have different permalinks based on category