If you are in a category context this should work and and you’ll get the correct catID to work with.
function getCurrentCatID(){
global $wp_query;
if(is_category()){
$cat_ID = get_query_var('cat');
}
return $cat_ID;
}
$catID = getCurrentCatID();
Related Posts:
- Get all categories and posts in those categories
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Combine two taxonomies in a hierarchical tree
- Get current category details the user is currently on in category.php
- Get the number of posts in a named category, outside the loop
- Test if post has a category
- Make parent categories not selectable
- I want to order categories based upon the latest post time
- Highlight current category in wp_list_categories
- How to find all posts without category and assign the “Uncategorized”?
- How to Override default update_count_callback for category
- How to select product category while adding new product in woocommerce? [closed]
- WordPress previous_post_link exclude posts with multiple categories
- Is it possible to put tags and category information in the post as text?
- Let visitors post comments on category page
- category_description() shows raw html after version 3.x?
- Is it possible to post with Word 2007 via XML-RPC and limit categories by user?
- how to get the categories for a single post in a hierarchical way
- Make parent category not selectable when it has child categories
- Want to hide some categories from the categories meta box in the post editor for the two specific user roles
- Getting categories id for all products in cart
- Can I use get_adjacent_post for specific categories?
- How to Filter categories in the permalink structure
- Accessing WordPress MySQL Database via Data Connection in Visual Studio 2010 using C#
- Is there a cleaner way to get post count for a category in category.php?
- products nested by subcategories in a current category archive
- get_the_category() always returns empty array
- Show archives by year from just one category
- Post count for category and tag
- Get current_parent_category in a loop or Cat ancestor- big problem
- Combining post categories and link categories?
- Is having thousands of unique categories a concern?
- How to prevent parent being choosen in wp_dropdown_categories
- wordpress sub-category ( lowercase letters + non-latin characters ) = 404
- Customize WordPress widget – Product Category
- Display categories with child category separated by letter
- How to make the link to the category for a post go to corresponding page number in archive?
- How to build a simple nav system of custom post type categories and its posts?
- Style category link depending on category ID
- How to insert category list into post creation page, and retrieve chosen categories?
- Shortcode interpreted as text
- Output category color option to each li item
- scaleability of tags
- Is there a way to only show Custom Meta Data on single posts from certain catagories
- Grouping post-types in loop
- Having problems with paging
- display a widget on specific category and its sub categories
- So my theme doesn’t have a category.php file
- Dropdown menu for subcategories
- Custom page category taxonomy 404
- Template hierarchy: how to let category.php conditionally-load archive.php?
- Adding custom ID field to the categories
- Getting Category Children
- Child Category Conditional Question
- Break down output of wp_list_categories
- Get the ID of the current post’s child category
- get category name in admin screen
- Return category posts with WP_Query
- How can i show categories of custom post
- Posts of specific category on page and excluded from index.htm
- How can assign posting to Subscriber to specific category?
- Include specific category in URL automatically
- WordPress Category Page Layout
- get_the_category – display only a single category for a post (not all categories)
- remove url from categories
- how to style show_count in wp_list_categories()
- It is possible to display related posts from same category as the current post?
- Categories are not available AT ALL under Menus
- Page category filter in admin dashboard
- Remove WP Core canonical for category pagination
- Create categories manually in database
- how to display specific Category if post have more one Category?
- Displaying a Category on a WordPress Page
- Is there a way to fetch the category of a page when using wp_list_pages?
- How to fix 404 error in pagination in categories of woocommerce with common url base /shop/?
- Hide specific category link from showing
- How to delete WooCommerce categories in bulk that only have one product
- Product Category page showing all products
- How can I add HTML classes for current taxonomy/term hierarchy into my pages to simplify styles?
- Display List of Categories Within a Custom Taxonomy
- How to remove specific categories from tag archives?
- add custom option to get_categories dropdown
- Category as subdomain
- How can I allow people to ‘subscribe’ to categories?
- get_category_parents displays an empty category
- Why is my post categories not displaying?
- Sort categories by meta value
- Unassign uncategorized from post with 2 or more categories
- Having Trouble With get_category_by_slug In a Custom Function
- WordPress category gives 404 after moving to a different domain
- Create custom Perma link
- How to load/include category templates based on conditionals?
- Why does WordPress append a bullet to my category tag?
- how to implement next/prev within category archive?
- Add product category to post_class
- How to get specific number of category post on a page or category page?
- Use same wordpress category base and tags as the prefix as the post permalink
- Display different sidebar based on search results from one category
- Adding category to existing post (uploaded file)
- how to create a page that shows all of multiple category posts on a single page