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
- Category and archive issue
- Display posts on a custom page from only a specific category?
- how can i display my posts alphabetically?
- if in category but only with post meta
- How to get post with associated categories and tags names instead of ids with rest api?
- Display a mixed list of posts and media
- Migrate posts from category and sub-category via SQL
- Does WP automatically tag posts into the archive?
- Parent category / child category posts
- Posts Missing in Dashboard after update
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Sort by last word in title
- Display post number by category
- How to create a page that shows the last 10 posts?
- Change Post Title For Specific Category
- Display selected categories onto post page
- How to call posts under a specific category on static front page?
- How to get the latest URL of my blog?
- Give posts a particular template based on the assigned category
- How to have more than one page for your posts if you have 8 posts but can store max 4 on a page
- Extract wordpress posts content and category content
- How to get post with slug and exclude categories
- All categories displays the same posts
- Having pages after specifying post_type post
- I want to show my post for limited time, how is it possible?
- Unable to differentiate between two categories under custom post type on single.php
- In what context should Categories and Tags be used
- Show posts on front page only
- list posts from two categories on a page – plugin not working
- How to set a certain Custom Template to a Single Blog Post
- Retrieving posts by their date and category
- Get latest post from categories
- How to create a playlist for audio associated with posts per category
- Are post, page and category IDs unique to each other?
- Change the background of each post according to the category
- Exclude a category of posts in author template
- How to edit the ‘
- Static pages not working
- Programmatically add posts from specific category to menu
- WP_Query of Category Not Showing First Post
- Sidebar on single.php not showing up
- Post is in descendant category not working in home.php
- WordPress displays post on subcategory only
- Where is the “Posts”/”Blog” template?
- How to get posts ordered by using their categories?
- Remove Featured Image from posts in specific category?
- How to show a featured image inside a post in only 1 single category
- Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?
- Display in category ( taxonomy) a number of post that I want
- Hide parts of the post content after typing it’s name or searching it by category
- SQL Bulk Move old posts by one author to another category
- How to display only one category in a custom post type?
- load more posts by category
- Get post category as a separate string and url
- Get only X number of categories
- Find out in which kind of archive am I
- Display Related Posts by Category in Random
- inserting a category into post
- Getting posts from some categories plus some individual posts
- Change layout of post depending on category
- How to make posts being uncategorized
- How to show category based post in home page?
- How to display a single(current) post from a category
- Sidebar limiting to 10 posts?
- posts going to 2 pages/categories only show up in 1
- displaying the categories post
- How to show beneath posts the full category path?
- What’s a theme that properly handles previews of different types of posts?
- Display Parent Category of a Post belonging only to Subcategory
- adding my posts (author posts) in menu
- How to separate each individual blog post?
- How to create a list of links to post with specific category
- How to list post as buch of category, and all of them
- latest post showing up twice on posts page
- wp_list_categories() Exclude All Categories Except One
- Direct some posts to only appear on a specific page
- How can I add a page that shows posts from a single category?
- Archieve page, Advertisement Every 3 Posts