And this is the indirect way I am using now. If there is any better answer please do share.
while ( have_posts() ) {
the_post();
$cat = get_query_var('cat');
$categories = wp_get_post_categories(get_the_ID());
if (in_array($cat, $categories)) {
...
}
} // end loop
Related Posts:
- Problem with multiple loops in wordpress theme
- Category archive by year with permalink support /category/YYYY
- 404 Error On Category and Tags Pages
- Force WordPress to Show Pages Instead of Category
- Decreasing the Memory Consumption of a WordPress Site?
- Check if current category has subcategories
- How to get the category of the post and link it to the archive (of the category)
- How to hide a specific category posts in my monthly archive?
- Optimal way to redirect home page to category archive?
- Display posts links from a category group by year
- Display list of Sub-Categories and the posts they contain, within one main Category
- Sort category page with custom field
- How to create tabled index of posts in a certain category
- Sticky Posts Not Sticking to Top of Category Archive
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- Category Specific Archive
- How to have Multiple Archives Widgets, one archive widget per category (in a different page)?
- “Sticky” posts for each category (archive.php)
- How to filter archives both by category and tag?
- Display “add to cart” button on every listing in product category page?
- How do I make the category template display full posts instead of partial posts?
- New Theme creation
- WP_Query() returns null when results exist!
- How to get data about category in category.php
- WordPress subcategories return 404 in custom template
- editing fonts of category links from the_category() funtion
- How to check category of of custom post type or not
- Set a them for all subset of category
- Show archives by year from just one category
- Archives for each category on WP Multisite
- Archive.php filtered by pre-determined category
- How do I call posts with a certain tag?
- Category being displayed without base parmalink
- How to change category and year archive permalinks/rewrite rules?
- Different templates for different category tags
- Restoring default article pagination on archives – Removing custom limits
- Category archive rewrite rule to include category/subcategory?
- Why category.php throw 404 in wordpress while calling paginate_links()?
- wp_dropdown_categories() scripts working erratically on sidebar
- Yearly Archive for Categories with dropdown
- Category archives with monthly pagination
- Woo Framework: woo_cat_featured not populating
- Question on using custom structures for categories
- Create a category archive page in TwentyTen Child Theme
- About title on a page
- How do I retrieve the category ID (ugly permalinks) in my sub-navigation menu?
- How to display post in custom file not in archive file?
- WordPress showing wrong category name
- Media (images, videos, etc.) not showing on Category page
- WordPress monthly archive category specific
- Show post categories
- Add description to categories menu in admin
- filter a loop base on specific category
- Displaying year once in category.php [duplicate]
- what file I need to create to work date archive links?
- How to add icon over specific thumb
- Displaying a custom field in Category Archives
- Add multiple orderby with pre get posts
- How to differentiate the homepage structure from the category page structure in WordPress template?
- How to detect /category and /tag base pages?
- show only sub categories if available?
- Redirect Problems with Archive Page and GET variables
- Archives and Categories in Custom Menu
- exclude certain categories form archive widget
- Show the number of the post
- Different post slug based on archive
- How do I make an array to get the category name, dynamically, in an archive template?
- How to prevent WordPress from redirecting single page to prefixed category archive with same name?
- In if…else condition, the else statement shows even if if statement is correct
- Show the parent taxonomy by creating shortcode in woocommerce?
- How Can I Display the Category Description in a Theme with no Category.php or Archive.php?
- Display Category yearly wise in wp
- Meta Box: display single image on an archive-template
- Media Library Categories
- How can I add HTML classes for current taxonomy/term hierarchy into my pages to simplify styles?
- Change single.php template based on parent category
- How to display total views of all posts of one category?
- Category archives
- Show posts from all categories
- Transfering static site to wordpress and retaining category by month paginations
- date.php shows all posts. how to fix it?
- Category base 404 – fix
- altering theme – content generated by PAGES not PORTFOLIO
- 2 loops in archive.php (one for each category)
- Archives and category of authors
- Search tag within category
- Determine the category that an archive-page is for
- Easiest way to display post archives in category-then-alphabetical order?
- How can i hide the authors box from a specific set of categories and post types?
- Get all first images of posts in same category
- All post of child category not in top category
- How to show monthly archive posts?
- how to implement next/prev within category archive?
- AZ Directory posts directory index
- How to link ACF relationship field to the new Query block in Full Site Editing
- Category archive page has two URLs even when default theme is active with no active plugins
- Sort Category Archive pages and place sticky posts first
- How to make /category/ URL load properly instead of 404 error?
- Is there a standard “Archive” block that shows ALL posts from a specified category?
- Display posts in a random order for a specific category