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
- What does the token %1$s in WordPress represent [closed]
- exclude multiple terms using get_terms() function
- Add custom field to attachments in a specific category
- Display all posts in current category
- How to display related posts from parent category
- How can I set custom order use this function
- Check if Product is in a Specific Category in Functions.php
- Use is_product_category() properly
- How to exclude specific category from the get_the_category(); array
- Category Thumbnail Display – How to display ONLY the main Category
- How do you use WP slugs for PDF files / media?
- Creating a related post section based on similar categories
- Swapping wp_dropdown_categories function with wp_category_checklist
- Show full posts in archive
- Issue adding sub category programmatically
- What query string parameter is available for index.php, that works for both pages and blog articles?
- php script to change slug in post automatically
- Grab posts by multiple categories
- 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
- Alert Bar section within WP loop is displaying even though there are no posts
- Different post styles depending on category
- Display category name only once inside loop
- Creating sub-categories via php
- Define specific category name in PHP
- Edit the_category (); for a hierarchical display
- Category title output before opening title tag
- 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]
- page-slug.php not working but only for specific slug
- How to hide posts of a specific custom category in WordPress?
- 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]
- Remove slugs from custom posts type
- random display categories – change url
- Output category list inside array
- 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
- First post article different on Archives template
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- Counting number of posts in multiple (sub)categories using shortcode
- I need to display posts in subcategory beside posts in main category
- Add Custom Category Description When Empty
- Order category posts by last word of custom field
- Add a product category to a specific product via a button
- Change category thumbnail size
- Displaying the Archive Page’s Name on the Page
- Display WordPress archive template page in 3 columns and not 1 column [closed]
- admin panel – How to remove “delete” button from category editing page
- Multiple Tag Filtering
- How to Link to category titles if it is in the single post content?
- Polylang and template files
- How can i show specific Category List?
- Notice: Undefined variable
- How to show category just on specific pages?
- How to filter specific element of an array in wordpress/php?
- Custom content using in_category
- How to add custom text near category/tag title in WordPress Twenty Fifteen Theme?
- PHP drop down menu for my get_category child of
- PHP get_category() function redeclared
- List categories assigned to a post
- Unable to get Post Category Name and URL
- Archive page if else not working for post_excerpt and post_content
- php string inside shortcode does not work
- Trying to see if page is category or single and displaying title with appropriate heading tag
- !in_array doesnt recognize category
- How to change links in the 3 main categories, on widget category, to a javascript function call
- how to set category name for a post
- category & sub category order issues in wordpress
- Show all posts in category
- Fix incorrect related posts code snippet
- Display a list of posts corresponding to a category
- Custom archives page by month and year – nesting problem
- How to create categories out of a list of words?
- Is there a way of displaying related posts from lowest hyrachical order (lowest child category to parent category)
- How to limit number of posts in the certain category and exclude the oldest post automatically