To get the category slug in a category archive page use:
$cat = get_queried_object();
$slug = $cat->slug;
get_queried_object fetches the currently queried object, e.g. the category object in a category page or the post object in a single post page.
Related Posts:
- How to show all posts of the category in wordpress?
- Exclude a category from WP_Query
- Custom Post Types on Category Pages
- Displaying category archive of custom post types
- How to list all categories and tags in a page?
- remove support for ‘Categories’ for a custom post type
- How to sort list of custom posts to get view like a tree of posts under categories and their children’s categories?
- Glossary with Custom Post Type
- Categories assigned to custom post type not found
- Displaying custom post type on category pages but not on blog listings
- Automatic category for a Custom Post Type
- Change / Delete the default post type and category?
- How to customize the Categories meta box to allow only one category?
- Restrict categories to a custom post type
- Is there a way to list posts of only a certain category
- Getting all custom posts with a certain category
- How to display the categories of the post? (custom post type)
- Display Custom Category (taxonomy) Name in Custom Post Type
- How to get category image custom post type taxonomy in wordpress?
- Query Custom Post Types & category_name?
- How do I get the child category posts from a custom post type?
- CPT posts listed by category with custom rewrite URL, please help!
- Return array of categories to php function for current post
- Multiple custom post type loops in category.php
- Pagination is not working on single-{slug}.php but works fine on page-{slug}.php
- How to get the post type from a category id?
- Insert HTML inside link in a walker
- Set menu active state for custom posttype and category, given custom taxonomy term
- Getting posts under the custom post type ui category
- wp_list_categories() – current-cat class also inside posts?
- How to display custom taxonomies with links in filter menu?
- Add custom post type settings to wordress default posts
- Hide parent categories when clicked, and show it’s childs
- Limit amount of posts made within a custom taxonomy
- Post injections into Site Origins Page builder [closed]
- WordPress posts page for customer filtering and sorting along with category filter
- Multiple (two) category postings on the same page.
- School & class blogs: Categorize with categories or custom posts?
- Why is my category template ignoring post type?
- How to get custom posts sub category link
- Not sure if I should create multiple custom post type [closed]
- Custom post types and category archive
- List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
- Categorise Custom Post Types
- Tag page only display 10 posts
- in_category for custom post types
- Can I restrict category availability?
- WP_Query Custom Post Type if Category ID Equals
- Custom post types and ‘new WP_Query’
- Showing custom post type categories in the menu
- Targeting categories in custom fields
- Creating Sections for Post Types
- Listing all slugs?
- Stores category posts in an array
- List categories, subcategories and posts from custom taxonomy and custom post type
- Custom post type categories gives 404 error
- Use post in multiple places on a page with multiple posts
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- Archive Template being used instead of Category Template for Custom Post Type
- Custom post type specific category box
- Custom Taxonomy Taxonomies of Same Name point to first created URL
- category.php not showing custom post types
- Post category behave like a Post in back office menu
- Save data is post using php front end
- Modify category permalink to use post type slug
- How to output custom post type title on custom page with category next to it?
- In the php, how can I have a category of a custom post type display?
- Create custom post type categories
- Pagination for a cpt filtered with a category
- assign array of category to custom post type
- Automatic Set Category For A Custom Post Type
- How to manage a dynamic multi-level page hierearchy system?
- Custom Post By Category
- Categories manage
- Adding Custom Post Types to category/tag/author archives breaks header content
- Change custom post type permalink according to category
- Change Custom Post Type to Post + Category
- Excluding category from loop not working
- Custom Post – additional param in the custom post URL goes to error page
- Update Cateogory Taxonomy Count for Attachment Post Type
- Help with Multi Level Category Archive Page
- can’t see categories in appearance-menu-categories
- Custom Post Type + Category archive
- Exclude categories For Custom post types
- How to call Shortcode categories for custom post types?
- Display all post types together
- Trying to create hierarchy between 3-4 custom post types
- Displaying wp post categories into my custom metabox
- How to filter posts by categories?
- Display a custom post type list by taxonomy term
- Stop header code from showing in category page?
- Custom Post Type order Title ASC
- Loop category including custom post type
- Highlight specific menu item when custom post is page
- Test if a Category contains certain Custom Post Types
- create category upon saving post and save post in that category
- How do I turn CPT automatically also into category?
- One set of categories for multiple custom posts
- Choose custom post type template by category
- Can a taxonomy of a custom post type be called ‘category’?