Please try below updated code
<?php
$recent_posts = wp_get_recent_posts(array(
'post_status' => 'publish',
'cat' => '',
));
foreach($recent_posts as $post) : ?>
<div class="card">
<div class="card-bg">
<div class="card-cat">
<?php
$category_detail=get_the_category($post['ID']);//Pass POST ID
foreach($category_detail as $cd){
echo $cd->cat_name.'';
}
?>
</div>
<img class="card-img" src="https://wordpress.stackexchange.com/questions/337072/<?php echo get_the_post_thumbnail_url( $post["ID'] ); ?>">
</div>
<div class="card-body">
<div class="card-title">
<?php echo $post['post_title'] ?>
</div>
</div>
</div>
<?php endforeach;
wp_reset_query(); ?>
Try and let me know if any query.
Hope it will help!
Related Posts:
- exclude multiple terms using get_terms() function
- Getting key value of WP_Term object in wordpress
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Archive listing of posts by publish year (multiple years)
- Add custom field to attachments in a specific category
- How to Remove Parents Category Permalink from Posts
- Looking to exclude blog posts from category Previous/Next buttons
- Put a link to a category round a hard coded A HREF
- How to exclude specific category from the get_the_category(); array
- Add HTML Attributes To Anchor Tags In `wp_list_categories()` Function
- Where do posts get the sidebar from?
- combine Code 1 with Code 2
- get post based on category chosen in drop down – The ajax method
- Creating a related post section based on similar categories
- Proper syntax or method for keeping url in modified isotope / category links
- Issue adding sub category programmatically
- Grab posts by multiple categories
- selected option if current category is the value
- get_template_part based upon post’s category
- how to save selected option in variable for rest api category filter
- Alert Bar section within WP loop is displaying even though there are no posts
- Different post styles depending on category
- Display category name only once inside loop
- Dilemma of Populating all the categories in a drop down list
- JSON REST API WordPress only showing first 10 categories
- Get all categories post is not in
- Get latest post from all categories except one
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?
- Only show size attributes in product box woocommerce when available
- Custom post type category not displaying category ID
- Argument for if term-> have child?
- How to get current post category details inside “loop”?
- Post not populating for custom post type based on category selection
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- Removing sidebar on category pages
- is user member of a group, show them categories [closed]
- Showing Subcategory Name/Link Instead of Parent Category
- WordPress custom taxonomy
- go to home page when i select default in select-box
- Finding and removing duplicates within WP Arrays
- Using multiple variables to assign categories to an array
- Compare current post Category in select menu
- Get the list of post categories
- Remove Custom Post Category In WordPress Slug Using .Htaccess
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Wrong Number of Products When Hiding Subcategory Products From Showing In Parent Category
- How to show categories and date on posts
- How do I edit the terms output args or array data?
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Allow two posts (from different categories) to have the same slug
- Get main parent category for post (WordPress/Advanced Custom Fields)
- Display Visual Composer shortcode if a post belongs in specific categories
- Category Page Displaying all Pages
- How to enable HTML tags in category description without breaking the category page
- Trying to show the category of a post in the post display
- Create category after theme setup and modify the default one
- Link to index.php from home.php?
- How does Permalink work with the AMP plugin after Removing Parent Permalink Catalog from Posts
- Hide a specific category title from displaying on site
- Return to the beginning of the results of a for loop
- Exclude category and post from loop in custom category.php
- Admin backend, show post from a category and exclude the posts from subcategories
- Populate Posts based on category selected using AJAX that means without page refresh
- random woocommerce categories are not showing when count enabled?
- Exclude a category slug on pagination
- Customizing the output of the archive and category widget without altering the original behavior of the widget
- How to Retrieve All Category Images on Front-End
- Short code into PHP
- Code works on page-example.php by not category-example.php
- Need Quick Help With Product Category Page
- get_category display only 1
- How to list categories by page id in wordpress
- Need to adjust condition to say if I’m pulling categories from a post, to pull only the first one
- WordPress using get_term to retreive slug not working as expected
- Showing the project type in HREF
- Front end post submissions do not get submitted in the category
- Make an array listing custom taxonomy
- Get category id for a custom category and display it in a class
- Trying to exclude posts from a category on the home page
- Search in particular category in wordpress
- Is there a way to randomize and connect a background and header image?
- wp_get_archive for category returning different URLs on different but similar sites
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- Error trying import one category on page
- dynamically filter by category via sub-menu
- Get unique post in parent category
- Code that displays images – images get shown multiple times
- Incomplete term slugs output from a foreach loop with get_the_terms
- Display post of specific category on page
- Displaying categories
- Remove /category/ from category (archive) page URLs (without using a plugin)
- Product Category Page in Full Width
- How to insert the first letter in uppercase [closed]
- Display all categories (with link) of custom post type – WordPress
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- Get category name of current post (CPT UI)
- Exclude a category ID from the following function
- Count post with tags within one category?