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
- How to get category and archive title?
- Get rid of WordPress category, tag and author archives?
- get_categories for custom post type with a specific custom taxonomy attached
- How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS Styling
- 404 Error On Category and Tags Pages
- What’s the URL for a category archive?
- Check if current category has subcategories
- wp_nav_menu not appearing for a couple pages
- wp_update_nav_menu_item() to insert categories
- Sort posts by tags in category pages
- How to get the url to tag & category base set by the user?
- Optimal way to redirect home page to category archive?
- How would you create a “weekly” archive?
- Sticky Posts Not Sticking to Top of Category Archive
- Root level category, tag, author and archive pages to work
- Are Custom Taxonomy Templates Possible?
- is_archive() content being shown instead of is_category()
- I want exclude the particular category in sidebar
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- Display only posts from referred category on date archive page
- Using widget logic I want to show only a widget on the archive page if there are no posts
- What type of page should i use? static page or category page? and what’s the difference? [closed]
- Creating archive pages for children categories
- Retrieve all posts within tag OR category?
- Edit the markup of categories list
- WordPress categories being called “archives” in google links. How to remove?
- conditional for sub category on archive page
- Sorting posts by season
- New Theme creation
- weekly archive for custom category
- WordPress subcategories return 404 in custom template
- How to remove category titles?
- How to call custom category field data in theme?
- Category index featured image
- How to change category and year archive permalinks/rewrite rules?
- Different templates for different category tags
- How can I define a custom archive for childs of a specific category?
- Get parrent category name
- add_rewrite_endpoint returns 404 on archives
- Multiple category archive page
- Custom archive.php: retrieve right post categories?
- wp_dropdown_categories() scripts working erratically on sidebar
- Yearly Archive for Categories with dropdown
- Customize category page for different custom taxonomies
- Inside a loop, how to change CSS class based on category name?
- Archieve.php not loading for custom post type
- Question on using custom structures for categories
- Category archive is displaying all posts rather than the specific category
- How to Remove a Title from All Category and Tags Page?
- Getting the category title / description returns first matching post?
- Do not show sub categories in the loop on archive-product.php
- why get_the_post_thumbnail( the_ID()) echos extra post id
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- display category list year wise in wordpress
- Category page returns 404 error
- WordPress monthly archive category specific
- Show post categories
- Add description to categories menu in admin
- filter a loop base on specific category
- Archive filtering
- Show Secondary Sidebar on Category pages (archive)
- Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?
- Add multiple orderby with pre get posts
- How to differentiate the homepage structure from the category page structure in WordPress template?
- WooCommerce shared categories
- List of post categories only associated to another custom taxonomy
- Products category search not working
- In if…else condition, the else statement shows even if if statement is correct
- Can’t display posts by filtering categories using isotope.js
- How to add excerpt and read more button to category archive page
- Display all posts from specific category
- Meta Box: display single image on an archive-template
- Make category archives page in menu non-clickable
- Custom Category Archive Pages
- custom browse by
- How to get get_categories()’s ‘hide_empty’ argument to work with global year var in the archive template?
- How to display total views of all posts of one category?
- get_the_terms_list output last child only
- How to get related category/categories in WordPress archive page
- Show posts from all categories
- Create monthly archive for parent category
- If it is a top level category show children otherwise show sibling categories
- Lowest catagory link
- How to count the number of monthly archive?
- Transfering static site to wordpress and retaining category by month paginations
- Conditional statements based on custom meta value in category archives
- How to get multiple loop in category.php, my scripts becomes madness
- altering theme – content generated by PAGES not PORTFOLIO
- Determine the category that an archive-page is for
- Easiest way to display post archives in category-then-alphabetical order?
- WordPress 3.5 how to determine if user is on category listing or category edit screen?
- Display only one level subcategory in wordpress
- Get all first images of posts in same category
- How to display the category featured images [closed]
- AZ Directory posts directory index
- 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?