$category_detail=get_the_category(get_the_ID());//$post->ID
foreach($category_detail as $cd)
{
$name_cat=$cd->cat_name;
$id_cat=$cd->term_id;
}
try now this code
Related Posts:
- Show posts without term
- Why is my WP_Query not working when tax_query terms are an array?
- Get list of posts which have at least one term from a custom taxonomy with WP_Query
- List taxonomy terms plus their latest post ordered by post date
- Get random terms
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- Order terms inside a select dropdown
- Get array of current post term ID’s
- How to add terms to my tax_query based off of the current post
- Change default ordering of taxonomy terms – pre_get_terms
- Empty tax_query array returns an empty array
- Pass array of taxonomy terms to wp_query
- Get list of terms that have posts in another term
- Formulate a url to show posts with both taxonomy terms
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Order by slug in get_terms with multiple taxonomies
- WordPress Related Post by tags in Single.php
- Function get_queried_object() return NULL in custom taxonomy
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- List custom taxonomy terms sharing posts with a term from a second custom taxonomy
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Get authors by term id or slug
- How to order posts by title after they have already been sorted by category
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Taxonomy order exception for specific term
- Filter Custom Taxonomy Posts
- Get posts from multiple tax terms
- How to Order a list of taxonomies? orderby?
- get_the_terms – but only show 4 Posts
- Count posts per taxonomy else change taxonomy if less than x number
- How to add custom meta to ‘pre_get_terms’?
- get term id from term name
- WP_Query to output chosen term and posts with no term assigned
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- How to print term name inside wp post loop
- Check if a post has term inside loop
- Grabbing taxonomy terms and inserting them into an array
- Deleting terms from the WordPress wp terms table
- Can’t get term id for category archive
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- How to make a post with certain taxonomy term display first before other post with only one query?
- How can I order a post query’s results based on the number of matching taxonomy terms?
- Only show tag with the same id as the post
- display ACF repater field in archive page
- Save queried result into database
- WP Query by 4 different taxonomies
- Get categories within specific term
- How to display Woocommerce products list by tag
- taxquery taxonomy get terms
- get term objects and post objects in query
- How to show terms from another taxonomy
- How to define a custom hierarchy for terms?
- Add a custom variable to query page object
- How to get several fields from wp_query?
- query only direct child and sub-terms of a current term archive
- Get access to all terms associated to each post that the wp_query loop displays
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- I need to get all categories from a WP_Query
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- Is it possible to completely stop WP_Query retrieving posts?
- Pagination returns 404 after page 20
- Make a WP Query search match exactly the search term
- Make loop display posts by alphabetical order
- Displaying several specific pages using WP_Query()
- WP-CLI How to generate a list of posts with corresponding meta values
- Warning: urlencode() expects parameter 1 to be string, array given
- All sticky posts are returned in custom query
- Can not switch the queried post in pre_get_posts hook
- Why use JSON API to display recent posts?
- Custom query for sidebar isn’t returning results
- How to vary post loop results layout and resume?
- Filtering WP_Query Dynamically on the Front-End
- Adding an array from a query string to a WP meta_query
- WordPress add_rewrite_rule() cannot visit lower url levels
- Using Advanced Custom Field for file upload, how do I load the file url
- Retrieve posts using thumbnail id as meta key
- Modify Search Query if original Query gave no results
- How to cache wp_query with pagination using transients?
- Problem with WP_query
- Why is WP_Query not displaying expected data?
- Filter post query to only show direct children of category
- Get every post with value in meta key
- Order WP_Query results by meta key value in custom query
- Display recent posts on another site
- WP_Query for products always returns empty
- Issue with data array format
- Wp_query…a type of term a different div
- Function the_posts_pagination() not compatible with WP_Query arguments
- WP_Query custom post with by general tags
- Why are my wp_query args being ignored if post_type = CPT
- How to pass a php variable to js within a template?
- Custom query: post__in parameter causes query to be empty
- Show subscriber id in loop
- WP_Query using meta_query with LIKE doesn’t return what it should
- How to organize a WP_Query’s list of posts by category and display category title?
- How to Query Updated Post in WordPress
- Query_vars not working for me
- Query posts only shows 1
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2