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
- How to show related posts by detecting the current category?
- Why does ‘get_the_ID’ work outside of the loop?
- Only display sticky post or latest post in custom loop
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- How to order posts in an arbitrary order?
- Is it possible to add/tick a category to a post when it is created?
- Excluding posts not working
- How many posts does the loop return?
- Posts loop displaying the same post data
- Display Posts on Custom Page
- How to make a sum of all posts displayed in a loop
- Possible to alternate between two loops
- How to get posts from a current post’s month?
- How to get a post’s content? [closed]
- Exclude current custom post on single post
- Hide posts belongs to few categories in homepage
- Wrong post title displayed from loop
- Get Value of Post before
- obtain the author id given the post id
- How to get posts and comments amount per hour, per year and per month?
- While loop articles – if statement order
- post category in wp_insert_post
- Multiple Loops Breaking Pages
- add to end of post in the loop with plugin
- Count number of posts of current month
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- How to get ID of the page included with get_page()?
- Recent posts per category loop?
- How to Get Posts, Including Private Ones?
- First x post with another template then the others
- How to get subcategories from category slug?
- Remove current category from post but display all others
- Loop doesn’t show title of second post and posts thereafter
- How show categories in admin and get that selected to show posts in index
- Change all author links in Blog roll
- How to I retrieve the ID from the Posts page?
- Random posts from a pool of posts
- Crazy Question – Updating Post ID
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- Second get_permalink inside loop points to wrong URL
- Change default category when I publish a post