On a category archive page, you can use get_queried_object()
to get the data of the current category in the main request, and get the slug like so: get_queried_object()->slug
.
Related Posts:
- Archive listing of posts by publish year (multiple years)
- Put a link to a category round a hard coded A HREF
- Get posts with at least one category in common with current post?
- How to query for pages/post depending on slug?
- Global variable $post returning incorrect object
- How do I remove a category from a wordpress loop>
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Allow two posts (from different categories) to have the same slug
- Get nice name of category from slug (remove dashes of category)
- Link to index.php from home.php?
- Hide a specific category title from displaying on site
- Exclude a category slug on pagination
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- WordPress using get_term to retreive slug not working as expected
- Weird slug in archives permalink
- get_category only returning details for ‘uncategorized’
- dynamically filter by category via sub-menu
- Hide empty categories from get_categories
- WordPress categories not working throughout site
- Issue adding sub category programmatically
- What query string parameter is available for index.php, that works for both pages and blog articles?
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- php script to change slug in post automatically
- how do I get a specific post from a post with a subcategory in WP
- WP grandchild categories in nested ul li
- Grab posts by multiple categories
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to show single category archive
- Move category description below post list in blog
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Get page that displays all children of taxonomy parent
- selected option if current category is the value
- get_template_part based upon post’s category
- how to save selected option in variable for rest api category filter
- Setting default category base on theme activation
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Different post styles depending on category
- Display category name only once inside loop
- wordpress archive a user
- How to show only subcategories in parent category not parent category?
- how to show only specific category for a template
- Redirect to another page using contact form 7? [closed]
- Dilemma of Populating all the categories in a drop down list
- Display most popular posts of category
- Creating sub-categories via php
- Define specific category name in PHP
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- List taxonomy term slugs within shortcode (do_shortcode)
- get taxonomy thumbnail and use it as a variable in code
- Include Parent Term in wp_list_categories
- How to array only one key from another array
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Get all categories post is not in
- Get latest post from all categories except one
- Using Shortcode to Grab Archive Listing, Separate by Year
- Displaying posts based on category
- Get categories names as an array to use it in theme settings
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- How to get the last category name of a child category?
- page-slug.php not working but only for specific slug
- In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
- Use get() method to grab all categories and output inside another method
- Issue with custom loop in Archive page
- Only show size attributes in product box woocommerce when available
- How to get category name or ID by post?
- Custom post type category not displaying category ID
- Argument for if term-> have child?
- How to get current post category details inside “loop”?
- How to separate categories with commas?
- How to hide posts of a specific custom category in WordPress?
- Show all tags within a category?
- Post not populating for custom post type based on category selection
- Add new post in existing categories using wp_insert_post
- How to change logo by category
- Problem with custom loop and wp_list_pluck [closed]
- Listing titles and custom fields of entries within subcategories
- Remove slugs from custom posts type
- random display categories – change url
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- Alphabetically Ordered Category in WordPress
- Output category list inside array
- Do not duplicate posts with multiple categories in multiple loops
- Loading Posts & Category with Ajax
- Removing sidebar on category pages
- How to get current category
- WooCommerce: Display product categories to make IF statement
- Trying To Get Child Categories To Show, Issue With foreach Loop
- Define category ID using get_post_meta
- Getting the slug into a variable, how to echo that variable
- How to Fix an Archive.php That Displays All Posts?
- First post article different on Archives template
- Show parent categories of the current category