you haven’t stated where the category id will come from, nor how you want to style the category title, and if the post titles are supposed to be linked to the single post; therefore just the basic structure:
<?php
$cat_id = 137;
echo '<div class="category-title">'.get_category($cat_id)->name.'</div>;
$cat_posts = get_posts(array('category__in' => array($cat_id), 'posts_per_page' =>5));
if($cat_posts) {
echo '<ul class="category-posts">';
foreach($cat_posts as $cat_post) {
echo '<li class="category-post">'.get_the_title($cat_post->ID).'</li>';
}
echo '</ul>';
}
?>
Related Posts:
- Only one category per post
- How to get permalinks with category base working with sub-categories
- WP 3.9 TinyMCE no longer loads on category description editor
- Change Gutenberg category checkboxes to radios
- Checklist of selected categories
- Exclude categories from search query
- Why is per_page not working with categories in WP API?
- How to order the get_categories result
- List posts by category exclude current post
- How can I calculate the total number of categories at different hierarchy levels?
- In the tag archive – display count of posts for each category they belong to
- How to add a background image to category and display image on category page
- Display only deepest category on a single post?
- How we add new categories by wp_insert_post
- Listing all posts from current category on page
- Show posts of one category only with Custom Taxonomy on single.php
- Hide uncategorized products from the shop page
- I want exclude the particular category in sidebar
- wp_list_categories() – adding a div to each li?
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- How Can You Exclude Categories From Your RSS Feeds?
- Help with multiple dropdown tags search
- How to get category URL with the slug?
- weekly archive for custom category
- ?cat=-1 Indexed Versions Of Homepage
- .htaccess too many redirects based on category slug
- How get permalink for the current category or tag?
- using checked function to verify value against an array
- wp_list_categories depth and number
- Category index featured image
- Order categories by most posts
- Exclude category from fucntion
- need to add custom field in more products
- How to redefine the sorting of product categories by menu_order?
- Filter Categories in meta box for CPTs
- Custom archive.php: retrieve right post categories?
- Add category only if post has custom taxonomy category
- Restrict author to create subcategory in a selected category
- Get posts from 2 different categories
- categories on attachment page
- A single category with a specific permalink structure differing from the standard set for the rest of the site
- List only child categories within posts
- Admin comments and user restrictions
- echo category description in single.php
- Get categories without post
- How to automatically check multiple categories on new post
- School & class blogs – renaming/archiving post categories?
- How do I get the parent category if I know the child category?
- How to exclude a particular category from the category list
- Hide specific category from wp_list_categories
- List just subcategory and products of active category page in Woocommerce
- Custom Meta Box (SELECT2) Not Saving Taxonomy Terms
- ow to display the number of posts in a category
- Force category choice before creating new post
- How to modify the “View all posts in category” title attribute
- Show post categories
- Exclude categories by ID
- Add description to categories menu in admin
- filter a loop base on specific category
- Display Sub-categories or Child Pages of Parent Cat/Page?
- How to check if a categoryID exists in a theme options page
- How to display product categories and number of sales on WooCommerce
- Display one category and its suncategories
- How to differentiate the homepage structure from the category page structure in WordPress template?
- Global navigation in multisite: problem with categories
- Placing category specific banner/html at top of respective category pages
- How to remove category name for only one category?
- Get parent category field from child category [closed]
- Custom sidebar isn’t showing up on sub-category posts
- Can a Woocommerce product category URL contain “&”?
- How can I display all products from all categories on one page with woocommerce?
- get_the_category return empty inside loop
- Unable to create pagination for Category.php
- Function add class to second menu specific items if the page has a certain category
- Posts says they are uncategorized but they are not
- How to call Primary Category for WordPress Woocommerce
- Meta Box: display single image on an archive-template
- I just want to list ONLY the child categories, but not grandchildren
- Search Replace Database ONLY for posts of certain category?
- Categories Help and video uploads
- Display only children of custom hierachial taxonomy
- Read More showing only on first post
- Filtered post assigned to categories
- Paginations in Category Page Leads to Sample Pages
- Allow a user to ‘subscribe’ to different post categories?
- How to exclude a specific categogy from a custom page template
- If on Category Page add “active” class?
- Transfering static site to wordpress and retaining category by month paginations
- Category Templates for Post Types not Working
- Change category base based on category
- Show only one category in main query, issues on tag page
- Bringing Ajax Loading Feature on Category Pages
- Need help with category page customization meeting certain condition
- Remove the current item from a menu
- Show category-ID in custom category-list
- Dynamically Adding Category Specific Content To Specific Category & Subcategory Pages
- Structure with category setting
- chose category in plugin
- Do not show all post from all categories, just show posts from category in current loop
- How to prevent page re-sizing for mobile browsers [closed]