Use:
get_query_var('category-name');
Which will give you:
example.com/category/subcategory/my_post
Which you can then put into any queries you make under category-name
.
You can see this in action using the Monkeyman rewrite analyser plugin, by entering one of the URLs for a post and seeing the query variables it generates using those rules
Related Posts:
- Listing Category ‘child_of’ by slug rather than ID
- Alphabetizing Posts in a Category Page?
- How to override Category rendering mechanism
- Why is this category page limiting the number of posts?
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Custom page for WooCommerce’s /product-category/
- Making a tourism information website [closed]
- display posts from specific category on a page , in thematic child theme?
- Page display certain Category Posts
- Add a custom category page in WordPress.org
- List all posts in a category with query_post() function
- Problem with different query loops (and “main loop”) on category template page!
- Home Page Template – Specific Category
- Template for product-category page [closed]
- Custom Page Template Category loop not functioning correctly
- How to differentiate the homepage structure from the category page structure in WordPress template?
- Assigning certain pages or posts to use the template of the parent page or category
- Add custom categories and subcategories and posts as custom pages
- How to edit woocommerce sub-category page
- Show alternative menu based on page template AND post category
- Own Custom Tags/Category page ( posts)
- Paginate WordPress Category Pages
- Dynamically Adding Category Specific Content To Specific Category & Subcategory Pages
- What defines a post as portfolio page content?
- how to create a page that shows all of multiple category posts on a single page
- 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 Default Post Category From Settings
- Get the number of posts in a named category, outside the loop
- Test if post has a category
- Categories – create a new separate set right after the default?
- 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?
- 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
- 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
- Is there a cleaner way to get post count for a category in category.php?
- Show archives by year from just one category
- Combining post categories and link categories?
- Category being displayed without base parmalink
- 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?
- Shortcode interpreted as text
- 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
- Custom page category taxonomy 404
- Template hierarchy: how to let category.php conditionally-load archive.php?
- Getting Category Children
- Break down output of wp_list_categories
- Get the ID of the current post’s child category
- get category name in admin screen
- How can i show categories of custom post
- Posts of specific category on page and excluded from index.htm
- Subcategory Page URL to Display Only Posts from that Subcategory?
- How can I display image child category in parent
- Limit categories to hierarchal depth of 2
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- Shop Category Pages missing s
- ADD DYNAMIC attribute for category to accordion
- Get_term_meta() does not work with pre_get_posts()
- Unable to add multiple categories to a post in WordPress
- How to display custom fields as table in Woocommerce
- make color of headline depend on category?
- How can I exclude a particular category from my WordPress Page 1 and Page 2?
- Menu with category 2 category combined
- Some subcategories not working on custom portfolio sort
- Link For Portfolio Categories
- Displaying Category in sidebar post widget but not in the loop on home
- Create duplicate category page with content variations
- Media Categories as Classes on WordPress Gallery Shortcode
- Category Template for Custom Post Type
- Loop Through Categories in Custom Field
- get categories the post was in and just been removed from
- Loop through posts of CatA and store value of CatB in separate array
- Highlight posts that belong to current sub category
- How to enable admins/editors to set a featured image for specific category?
- Problem with single posts not showing correct category sidebar
- Multiple Categories under one URL, where ‘Front Page’ is used already
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- Having Trouble With get_category_by_slug In a Custom Function
- WordPress category gives 404 after moving to a different domain
- 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?
- Limit authors on specific catogories