I figured it out. Here is my solution
<?php
$categories = get_the_category();
$category_id = $categories[0]->cat_ID;
$mymain_query = new WP_Query( array( 'cat' => $category_id,'posts_per_page' => '10' ) ); while($mymain_query->have_posts()) : $mymain_query->the_post(); ?>
//shortened code below
<div class="blog-post">
<h5><?php the_title(); ?></h5>
<p><?php the_content(): ?></p>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
Related Posts:
- widget should display post archive by year and on click also by month
- Display most recent post in category instead of archive?
- Single.php Active Category Class
- get_post_type_archive_link(‘post’) returns current category archive
- Category List (Archive) Page Template By Category
- Single.php – Get Current Parent Category
- singular posts using archive styling
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Exclude post category in a blog page
- Post-Archive like a page in a specific subdirectory
- How to view all posts (on site, not admin) that are uncategorized?
- Highlighting Current Category in the Archive and Feeds page
- How can I create a ‘sub-blog’ which has its own sidebar on individual posts?
- blog post not accesible on click [closed]
- Posts are not displaying on their category and tag page
- show image gallery in archives or category page
- Edit Posts Page but not category specific pages?
- How to organise post by category and date
- How to set a link to custom archieve page
- How to get pagination working with “Pending” Posts
- Show all posts in category
- how to show all post with its contents
- How to get the number of posts in a selected category?
- Show related posts by category but ignore one category
- How do I convert a mathematical Microsoft Word document to a WordPress blog post?
- Add custom field to category of custom post type
- Can I hide a specific post from latest posts page?
- How to get the latest posting time of archived pages in WordPress?
- How to show post(excerpt) from specific category on wp page?
- Custom Theme Want To Remove One Category From All Displays
- Divide Loop Into Days & Categories
- Different template for posts of all subcategories of category
- Limit Gutenberg blocks available to users to choose from
- Mark menu item as current-menu-item for category
- How to set up multiple taxonomies for groups of posts
- Remove certain post-formats from showing in blog?
- How to display category from recent posts?
- Blog Posts in Custom Menu
- How to display data in archive page?
- Can I divide the pages into categories?
- Duplicate posts and change category
- Category Foreach keeps looping?
- Archiving by academic year instead of calendar year
- display a random post thumbnail from a random category
- Post page to display specific category
- how to show single post in a custom template
- How to remove in-line style of WordPress’s post content only?
- Excluding posts not working
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- Remove current category from post but display all others
- How do I show posts from another wordpress installation?
- Why won’t pagination work?
- How do I include the category next to the title of a post?
- How to show a custom taxonomy in the theme?
- How to import nested categories from XML file?
- Migrate posts from category and sub-category via SQL
- Posts Missing in Dashboard after update
- Display post number by category
- How to get post with slug and exclude categories
- Retrieving posts by their date and category
- Are post, page and category IDs unique to each other?
- Static pages not working
- WordPress displays post on subcategory only
- Find out in which kind of archive am I
- Categories Listing and Highlighting current category item
- Changing The Default Header POST Title and Description text by category in wordpress
- Display hierarchical categories/sub-categories for a single post only
- why my urdu text is not aligned properly when written in wordpress blog post?
- Sticky Post Doesn’t always work
- Single Post Gallery Using Shortcode
- Author post count in category
- Why do I have categories with duplicate slugs?
- How to generate an HTML link automatically from URL in a users’ post
- view a list of 3 future post, from the nearest to the most far
- Automatic Table of contents with categories and posts
- Re-order Category Meta-data
- Custom post styling per category?
- post categories – how to show only categories with a specific parent id
- Creating a “category” of featured posts
- How do I make it so that new posts within a certain category go into a certain page?
- List Authors For Current Category
- List posts of assigned categories in list of all categories on single.php
- Hide first blog post in content and output it in widget
- Assign specific ads to specific categories/posts
- find posts with exactly 3/4 categories
- Use radio buttons & checkboxes for post categories
- new blog post does not appear in blog after publishing
- Displaying only posts from a certain category on my custom page template
- WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1
- Add default content to post (for specific category)
- List posts that are in the same category as the current post title
- Wanting to apply different featured images for each post
- Multiple blog “feeds” in a single blog each with distinctly styled post pages
- Post only showing on homepage when Logged in – direct URL still working
- Post’s arent displaying
- Show with echo if a post has two or more categories
- How can I get on the same row two post of different categories?
- Display post count on archive page in reverse order
- Filter/Sort Post Form On Taxonomy page
- Filters do not work when there are multiple (one works)