You should use get_the_categories()
Returns an array of objects, one object for each category assigned to the post. This tag may be used outside The Loop by passing a post id as the parameter.
$categories = get_the_categories();
var_dump( $categories );
Related Posts:
- Showing current subcategory
- loop mix my child-category and parent-category
- Get the children of the parent category
- How can I custom order the results from wp_list_categories?
- wp_list_categories: get latest featured_image of category
- Exclude category by slug for for each loop
- Display page of custom posts?
- Why is my loop not dynamically grabbing the correct Category and displaying all categorized posts?
- Query Posts Exclude Entire Category
- Publish Categories for a particular Author on a given Post
- Showing categories and subcategories with posts
- Loop Problem: Displays same set of post for all categories
- Category ID returns as ‘0’?
- Three Column Loop
- Exclude category from get_the_category
- Display all categories as plain text
- loop inside a loop : search for posts in the same category
- Secondary loop cuts off at 10 posts?
- Need a conditional to test if title of parent page matches title of child page
- My custom query not detecting the correct category
- Show last post from multiple categories using wp_list_categories
- display post pdf attachments in side bar with link text
- How to display fields from the loop in two separate divs
- Loop only shows first two posts
- Why is my archive page looping through all but one post?
- Template category.php with page (no posts)
- Loop two different category WP_Query
- Adding a second loop breaks everything
- Use ACF Category Image for all Taxonomy Archive Views
- Solved – Inserting content inside the WordPress loop
- How to show related post with category DESC (ASC) IDs of ID current post
- WordPress posts in the loop not stacking side by side
- WordPress posts loop not displaying all posts on blog
- Display all the terms within a custom taxonomy
- get_page_by_title not working inside fucntions.php
- Current post categories and subcatecories outside of the loop
- A code that I could not fully grasp related to foreach & count_user_posts()
- Need to while loop and display contents in the subfield of a group field given by ACF
- Get categories within specific term
- How to use single.php output in function.php
- How to separate post titles with a comma in the loop?
- Custom Query with Sticky Posts
- Add Search and Filter functionality to custom loop
- Loop with custom posts, to include information from different custom post type
- how to add 4 post in one carousel slide
- Custom WordPress theme not displaying posts from category
- error in specific category loop
- How to add “NEW” badge on latest posts or published 3 days interval
- Submit form for loop of products of the term with AJAX
- How to show specify category template for both parent and child category
- Only Show Excerpt After First 3 Posts
- loop in single.php of the same category
- Add all category as classes in foreach loop
- How to get all multi-select user meta values and add them to an array?
- Duplicate posts on archive page
- get_posts changes main query
- Exclude posts from loop by term
- Trying to get property ‘post_content’ of non-object
- How to distinguish pages created by woocommerce?
- Pagination for a cpt filtered with a category
- Bootstrap tabs are not being clicked in WordPress loop
- Return to the beginning of the results of a for loop
- Get gallery in loop through ajax
- Archive: Lists itself
- How to create a category loop on my blog (ACF Plugin)
- Please tell how to stop the category from showing up on posts
- Hide a category/posts from the homepage in wp
- How to show the last article in a different way in my blog?
- Exclude category and post from loop in custom category.php
- Last post in loop when even
- Get a specific size from wp_get_attachment_image_src
- the loop printing post in one grid
- Check value of post meta within IF statement
- How to insert content before pagination in loop?
- Pagination on a underscore custom theme
- My WordPress installation doesn’t load correct template
- How to display a loop of custom post types in columns
- Use the loop to check if DB record exists?
- Loop by category and meta_key
- Build a Page which shows the Oldest Post with specific Custom Field Value
- WordPress multiple loops with default pagination
- Loop random posts and display odd and even based on two alternating meta values?
- How to resolve a reload loop issue in the frontend when logged in to WordPress multi-site backend admin area
- Can’t limit posts_per_page in loop
- Display 3 levels of categories on page
- WordPress loop : how to exclude some posts with their status?
- WordPress + Isotope: how to give different widths to each entry?
- Exclude Posts Using Meta Query and User Meta
- is it bad to copy the loop for a template?
- Customizer settings using “for” loop
- I want to load post in bootstrap Modal dynamically
- hide woocommerce tab if empty
- Is “the loop” a template tag?
- Why my loop is repeat?
- Excerpts not showing on main page
- Reorder posts in a loop: have the posts by one particular author below the others
- Custom post type loop without children
- Get top Page IDs from menu and cycle through their child pages on a scroller
- Include only one category but Exclude if is in a category from loop
- Work arounds for conditional checks inside the loop in search.php?