Try this code.
<?php $cat_id = get_theme_mod('cat_choose', $defaults); ?>
<p><?php echo get_cat_name( $cat_id ); ?></p>
<hr>
<?php
$args = array(
'post_type' => 'post' ,
'orderby' => 'date' ,
'order' => 'DESC' ,
'cat' => $cat_id,
'posts_per_page' => -1,
);
$cat_posts = new WP_query($args);
if ($cat_posts->have_posts()) : while ($cat_posts->have_posts()) : $cat_posts->the_post(); ?>
<div>
<div>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?></p>
<p><?php the_time('F j, Y'); ?></p>
</div>
<div>
<?php the_post_thumbnail(); ?>
</div>
</div>
<?php endwhile; endif; ?>
Display Category Name using Category ID
<?php
$cat_id = get_theme_mod('cat_choose', $defaults);
echo get_cat_name( $cat_id );
?>
Related Posts:
- Get Posts Under Custom Taxonomy
- How to show related posts by category
- get all posts ID from a category
- Display all posts from specific categories on a page
- How to show list of posts by author and category?
- get comments and get posts in loop
- Query only Posts from Both of Two Category?
- is there a better way of combining this?
- Showing random content / pictures from earlier posts in a sticky post?
- Divide Loop Into Days & Categories
- Posts are not showing up on particular category
- How to filter posts that belong to a specific category only if that is the only category
- get_next_post() and get_previous_post() return wrong posts
- Inserting custom data to the_post() during loop
- Display post category in foreach loop with category link
- How do I restart my loop with get_next_post()?
- Get mixed category random posts
- Child_of not displaying all children posts.. via get_posts
- Exclude category from
- Pulling in post category and children within category
- Post Loop Missing Most Recent Post
- Get Posts Under Custom Taxonomy
- Get attachments for posts that belongs to a specific category
- Pagination with an array of post objects?
- Listing Specific Categories from Current Post with Depth
- How to make the first post in the loop be styled like a “new / featured” post?
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- why does wordpress ignore the post args?
- Showing categories and subcategories with posts
- How to create a “latest news” page showing a list of posts from blog category
- How to get post with slug and exclude categories
- Accessing Post ID Within Loop
- Are post, page and category IDs unique to each other?
- The loop starting at a certain ID
- linking to post outside the loop
- WP_Query of Category Not Showing First Post
- Get post category as a separate string and url
- posts going to 2 pages/categories only show up in 1
- Get current taxonomy and display query accordingly
- How to add content above footer in posts from specific category
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Current post categories and subcatecories outside of the loop
- How to distinguish pages created by woocommerce?
- How to show category image if no featured image is set?
- How to Get Position of a Post from a category and tag
- Display new posts categories in separated divs
- How to get all posts in gallery post format template
- List Authors For Current Category
- Multiple Post Repeat for Related Post Loop by Category
- Show post if in category
- Retrieve latest post by multiple categories with ID
- Displaying categories items among posts
- Make assigning post to a specific category equivalent to assigning it to all categories
- Displaying posts on Homepage
- Show all posts in category
- wordpress show category link instead of post link [closed]
- posts_per_page – Repeats only first posts ‘post__in’ array
- Inject post (from specific category) between posts in Loop
- WP_Query: Why is sticky post not first item in loop?
- how to display full post with pagination on home page
- How to use alternate post layout at key points in post loop?
- What Defines What Category A Post Picks (if in multiple)
- Double count view in archive.php
- Different style for most recent article
- Differentiate between posts and pages in search results
- Extracting post categories
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- Get user categories with most posts in it
- How to display two blog categories as separate sections on one page?
- Retrieve post ID from “querying” URL
- How to make a sum of all posts displayed in a loop
- First x post with another template then the others
- Loop doesn’t show title of second post and posts thereafter
- add bootstrap post slider with tabs
- How to add add more properties to WP_Post object in search results loop
- get posts from Custom Post Type & Category
- Add Blog to WP homepage Manually
- How to show all posts by author on buddypress profile with navigation
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Different post views for different category views
- How to select a category automatically based on a word in WordPress post title?
- How display related post only in Default category on single
- How to merge the content of posts that have the same title?
- How to add first 3-4 post tags on WordPress Post Title
- How to add class to specific navbar item when post parent category is in specific category
- Posts are not displaying on their category and tag page
- Posts page listing pages as well
- Post Category link is same with Page link
- Show custom post category for single post
- Get a list of categories that are related to posts
- Loop through posts by each term and exclude duplicate posts assigned to several terms
- Is possible to create a custom link that creates a post that’s already categorized?
- How to display subcategory articles in the category view?
- Only show posts with image and the correct ammount of posts in loop
- Related posts by searching post tags of single post as terms
- What template file is used by default for posts?
- What is $post->ID
- Sort Posts Alphabetically Based on Specific Category (Divi)
- I have a website issue I am trying to resolve