First you have to create secondary loop and use it.
// $categories = wp_get_post_categories($post->ID);
$categories = get_the_category($post->ID);
foreach ( $categories as $category ) {
echo $category->name;
}
Description
get_the_category( $post->ID );
This tag may be used outside The Loop by passing a post id as the parameter.
Note: This function only returns results from the default “category” taxonomy. For custom taxonomies use get_the_terms().
Related Posts:
- WordPress Orderby Numeric Value Not Working
- Post image in WordPress not appearing on home page
- Update Post Meta for a logged in user
- Two Custom Post Types Many to Many Relationship
- Update postmeta Parent when post_status child change
- Batch Extract Date from post title and put into ACF custom field
- Get_post_custom not fetching value from array wordpress
- Add a form in every post and save data in post meta
- SELECT custom post type and its meta in SQL
- Save data is post using php front end
- Show posts from WP Custom Post Type selected from a field in a metabox
- How to properly get the wp_postmeta.meta_value of a custom post type in specifics?
- update a posts of other custom post type
- Edit post meta direct from post.php?
- How to create content automatically when a post is published?
- Display a post count from a custom metabox selection
- Top 30 Songs using Custom Post Type
- Automatically add custom taxonomy when meta value gets to a set number or beyond
- Get the ID of the latest post
- Change permalinks for posts but not for custom post types
- Front end post editing using a form
- Set posts of a custom post type to be private by default?
- Ordering posts having multiple post-meta date fields
- How make get_next_post() return first post when viewing last one
- modify all posts of a category to “no comments allowed”
- Getting a div content of a post in wordpress?
- ascending order custom post type
- add_meta_box: Datepicker like the one for postdate?
- How to show post title outside of loop? [closed]
- How do you use JavaScript to detect the homepage
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- Trying to edit the single page from a Custom Post
- How to Submit Post Via cURL & PHP
- apply filters only to specific post listing without check the url parameters
- is there a way to retrieve posts that do not have a featured image assigned?
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Undefined Variable – Custom Post Type Meta
- Missing Posts in Custom Taxonomy List
- How can i add thumbnails images to particular post (using code not admin pannel) in wordpress
- Showing posts from different categories and from custom post type
- changing meta value and meta key of price field
- Posting to a Custom Post Type from front end – user generated content
- Restrict Access to Posts based on Custom User and Post Meta Data
- Custom Post Slug same as Parents Category Slug
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- How to get all tags of a custom post type by id
- How to define which register_post_status goes to which register_post_type?
- Load Next WordPress Posts With AJAX?
- If there is only one post (show elements) else (show other elements)
- create custom meta box with default value
- How to move a post to different post type with all meta data?
- Custom post type menu
- WP API Response does not show my registered metadata
- How to detect that the save_post hook is calling the callback associated to the current edit post page only
- How do I edit the WordPress post.php file?
- Posts are not rendering perfectly [closed]
- How I can made a custom post type to page templates?
- Problem with adding custom post type meta to header by plugin
- Echo custom post meta from options array
- Value of post meta dropdown is not showing in WordPress
- List all posts in taxonomy term
- WP_Meta_Query object with conditionals
- Trying to write shortcode with get_post_meta but isn’t working
- how to redirect to a custom post template
- Post/Custom Post Type URL Access
- Adding /blog in front of single posts (only)
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Search CPT by tag ids
- Post template with breadcrumb needs to show page navigated from
- Define multiple prefixes for custom post type
- Publishing failed. The response is not a valid JSON response
- add all blog posts to folder
- How to show posts of the same category on a page?
- Peepso: Add extra data field (custom post meta) to postbox
- Change picture attachment meta of all occurrences of a picture
- Unknown Post Meta Records
- Get Previous Post based on Custom Field Name, for Custom Post Type
- Saving custom post types post_meta over REST-API fails
- custom post type to post association in wordpress
- Need to display author’s email id in the “Edit post” field in wp dashboard. How do I do this?
- How to get all posts related to a taxonomy?
- Work and Display a Custom Post Type as a normal Post
- Stripe multiple transactions
- Most efficient way of showing children posts?
- Custom post type with two templates
- One Post with different content, depending on a Page
- Popup panel is only displaying 1 entry ignoring all others
- How to display data with pagaination on backend?
- How to Arrange Support => Thumbnail
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- Change the contents of a dropdown through the admin panel?
- fetch meta fields inside a widget
- Use a Variable in update_post_meta as the $meta_key
- How to delete unnecessary custom post types in the UI
- show the most recent date of all posts to display on front end
- Error 403 when posting comments to a custom post type from a different page
- Changing to different post type maintains the redirection?
- Sort ACF by custom taxonomy
- How do I add the “orange counter” next to a Custom Post Type?