$wp_query->get_queried_object()
will give you the “currently queried object”. On a category archive this is the category object, on a author page this is the author, on a single post this is the post itself, … well, you get the the idea. If you only want the ID you can also use $wp_query->get_queried_object_id()
.
Related Posts:
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Force category choice before creating new post?
- How to remove category from wordpress url?
- How to create a custom url for a category [closed]
- How to get primary category name in WordPress new version
- Rearranging posts based on categories
- How to create category index table out of wordpress site or on other website?
- Custom Nav Walker menu – Display category count
- Multisite blog converting categories to subdomains
- Using URL parameters, list posts from category and custom taxonomy
- Display posts links from a category group by year
- List categories for author: list_categories function inside list_authors function
- Redirecting specific category to subdomain
- Hide a certain category name without removing it?
- How to make all posts in a category sticky?
- WordPress: category page not for post’s
- Automatically assign posts by author to a specific category
- How to show empty category in admin menus search
- Categories and Tags returning 404 on the sidebar when using ugly permalinks
- How do I remove the tags from wp_list_categories?
- How to insert category and subcategory using ‘wp_insert_post’ function?
- Show posts of category in a page
- How to create taxonomy values for pages and list them in wp-admin
- How to display get_the_category of post showing only CHILD of category “X”
- Get ID of current taxonomy in register_rest_field
- display woocommerce all category title on home page
- Custom page for WooCommerce’s /product-category/
- Add Class While on Current Post; wp_list_categories
- get all sub categories without specify any category
- How to use wp_category_checklist()?
- Get the name an the description of a link category
- Display child categories in WooCommerce
- WooCommerce duplicate sub categories and product slugs
- Check child/parent categories if exists
- How to run select query of post with category and tags for API?
- How to show only one category in breadcrumb navigation
- Trying to only display 1 category using get_posts
- How to display singular form of category name?
- Populate dropdown based on selection of parent category
- Custom User-Created RSS Feed
- query cat orderby and order not working
- WooCommerce – How to show specific category first-rest of products-specific category last
- Multiple URL’s based on category for one post
- WordPress category check
- How can I improve this taxonomy treating approach?
- Exclude categories from wp_list_categories by category slug
- How to show more than 5 posts of the category?
- Can’t delete a category in WordPress
- Dropdown Categories used in form shows no results when all is selected
- Nicer URL for viewing category of posts?
- Get Categories Where Taxonomy Equals ‘n’
- Odd results in get_the_terms vs wp_get_post_terms
- How to access deleted term inside delete_product_cat action
- get full category structure by post id
- Remove Archive | from Categories
- Showing Categories for Page Edit – without plugin
- Using categories with pages
- Show next post in same category but start from the latest
- Only first category!
- How could I write a get_categories_by_year() function?
- How to add icon over specific thumb
- add_settings_field (exclude categories->reading) wp_category_checklist
- Retrieve post tags from from main wp_query
- Can I define multiple paginations on a single page?
- Echo Category Nicename
- Explode() expects a string
- How to add meta description, keywords, custom title to a category template
- User level categories
- Exclude category from drop down list form
- How to set the same base url for two different taxonomies?
- Programmatically Create Category and sub Category and sub sub Category
- Parent Category and Subcategory default text generated with category
- How to create a table with counts of category combinations?
- How to get the_category(‘, ‘) with link “title” attribute
- product_cat image url from database
- How to get the term id inside the start lvl method of category walker?
- Multiple if statements with else for get_the_category [closed]
- Most efficient way to display current post subcategories?
- Using a template page parent breaks page
- How to Query the Top 5 Posts of a specific category?
- Setting category for post as default
- How to add a post with new Taxonomy without assigning to default category?
- Query post only from categories that have subcategories
- How to get the link of all categories
- foreach,having wp_query inside, breaks after showing one result
- Display a category name automatically using code in the functions.php file
- Tracking multiple tags or categories
- 2 loops in archive.php (one for each category)
- How to load jquery tag-it plugin into admin?
- Include Category Description in search result
- not empty categories don’t show in menu [closed]
- Show parent-child relationship for categories in the wordpress admin
- How to assign different categories to pages in wordpress?
- All post of child category not in top category
- How to add a tag above a category post that displays the category name in WordPress
- Woocommerce – Display product category of product in Orders page
- How to show video from wp option value?
- Changing Woocommerce categories programatically
- How to link ACF relationship field to the new Query block in Full Site Editing
- Order Categories by Character Count