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)
- Global $post value outside the loop
- Show category name in category.php when posts assigned to multiple categories
- Category and archive issue
- Display posts on a custom page from only a specific category?
- Using ajax on editing a category edit page?
- Related posts by category not working right
- How to list recent posts in a wp nav menu?
- Set Default Category to Username
- Disable sticky option for specific categories
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- How to add tags (custom taxonomy) to post class css?
- How can I hide tags on a child-category page, if that tag has not been used?
- date issue with category post retrival
- List authors with the last post title and order by last post date
- How to exclude visited posts from loop
- How to make multiple sections in home pulling posts category wise?
- Use two different post_per_page limits with infinite scroll
- How to display excerpt post on hamepage and archive pages?
- How to display two blog categories as separate sections on one page?
- Increase 10 post limit per page
- wp_query random post
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- “Right Way” to make custom Loop respect reading settings inside admin panel?
- How to setup a query to output posts by groups of five?
- Redirect to another page using contact form 7? [closed]
- Only display sticky post or latest post in custom loop
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- How to order posts in an arbitrary order?
- Automatically create a new page daily with last three posts
- Is it possible to add/tick a category to a post when it is created?
- Excluding posts not working
- How many posts does the loop return?
- Display Posts on Custom Page
- How to make a sum of all posts displayed in a loop
- Possible to alternate between two loops
- How to get a post’s content? [closed]
- Exclude current custom post on single post
- Hide posts belongs to few categories in homepage
- Wrong post title displayed from loop
- Archiving posts in wordpress
- Get Value of Post before
- post category in wp_insert_post
- Multiple Loops Breaking Pages
- add to end of post in the loop with plugin
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- Recent posts per category loop?
- First x post with another template then the others
- How to get subcategories from category slug?
- Remove current category from post but display all others
- Loop doesn’t show title of second post and posts thereafter