to get the category slug of the category archive:
$cat_slug = get_category(get_query_var('cat'))->slug;
alternatively, to get the category ID of the category archive:
$cat_id = get_query_var('cat');
Related Posts:
- Use category base slug in posts’ permalink
- Display all posts from specific categories on a page
- How to show list of posts by author and category?
- How to control which category will be picked for the slug of a post?
- Display most recent post in category instead of archive?
- Single.php Active Category Class
- get_post_type_archive_link(‘post’) returns current category archive
- How do I get the slug of a custom taxonomy category of a post?
- Divide Loop Into Days & Categories
- How to filter posts that belong to a specific category only if that is the only category
- Category List (Archive) Page Template By Category
- Display post category in foreach loop with category link
- Child_of not displaying all children posts.. via get_posts
- Exclude category from
- Pulling in post category and children within category
- Listing Specific Categories from Current Post with Depth
- How to make the first post in the loop be styled like a “new / featured” post?
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- why does wordpress ignore the post args?
- Showing categories and subcategories with posts
- singular posts using archive styling
- Post-Archive like a page in a specific subdirectory
- WP_Query of Category Not Showing First Post
- Get post category as a separate string and url
- posts going to 2 pages/categories only show up in 1
- How to view all posts (on site, not admin) that are uncategorized?
- Highlighting Current Category in the Archive and Feeds page
- Get current taxonomy and display query accordingly
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Permalink Short code showing unnecessary link text inside the loop
- Current post categories and subcatecories outside of the loop
- Posts are not displaying on their category and tag page
- How to 301 redirect from url with post id to permalink with post name (slug)?
- How to distinguish pages created by woocommerce?
- show image gallery in archives or category page
- Get posts from category from custom query
- How to show category image if no featured image is set?
- Display new posts categories in separated divs
- List Authors For Current Category
- Multiple Post Repeat for Related Post Loop by Category
- How to organise post by category and date
- Show post if in category
- Displaying categories items among posts
- How to set a link to custom archieve page
- Make assigning post to a specific category equivalent to assigning it to all categories
- How to get pagination working with “Pending” Posts
- how to show all post with its contents
- View post with specific category id and name which I selected in the backend (drop-down option)
- How to get the number of posts in a selected category?
- Display list of Sub-Categories and the posts they contain, within one main Category
- Count singular post views automatically
- Looping through posts per category gives same posts for each category
- Exclude category by slug for for each loop
- How to get the latest posting time of archived pages in WordPress?
- custom wordpress post loop – hide iframe content
- Different template for posts of all subcategories of category
- Mark menu item as current-menu-item for category
- How to display different number of posts
- How to set up multiple taxonomies for groups of posts
- How to display category from recent posts?
- Best way to assign post position in a news site homepage? (no categories, no sticky posts)
- How do I restart my loop with get_next_post()?
- Post page to display specific category
- how to show single post in a custom template
- Excluding posts not working
- Remove current category from post but display all others
- How to only publish posts with image in it
- How do I include the category next to the title of a post?
- Migrate posts from category and sub-category via SQL
- Posts Missing in Dashboard after update
- How to get post with slug and exclude categories
- Auto update post title and slug when post status is changed
- Accessing Post ID Within Loop
- Retrieving posts by their date and category
- Are post, page and category IDs unique to each other?
- Different number of posts per row in grid layout
- Static pages not working
- WordPress displays post on subcategory only
- Categories Listing and Highlighting current category item
- Author post count in category
- view a list of 3 future post, from the nearest to the most far
- Automatic Table of contents with categories and posts
- Need help with hiding an image within a post in a category
- WordPress not showing recent posts
- How to filter out post from a category not its subcategory in wordpress dashboard
- How can I display a specific number of post in a category via a url
- How to display term in archive page?
- Keep post format class with isotope filter
- Sort post by category using HTML Select tag
- How to get alphabetic listing x other posts, based on first letter post?
- Sort by category and then date?
- Loop not allowing infinite scroll after post per page limit
- Customise the appearance of 4 specific post ID’s within the loop?
- what template-part to call, to have my post in the center of the page?
- Exclude a ‘portfolio’ custom category?
- How do I show the post title if an advanced custom field hasn’t been used?
- Post’s arent displaying
- Show with echo if a post has two or more categories
- Sort Posts Alphabetically Based on Specific Category (Divi)