Resolved using this:
<div>
<ul>
<?php
$current_category = get_queried_object(); ////getting current category
$args = array(
'post_type' => 'page',// your post type,
'orderby' => 'menu_order',
'order' => 'DESC',
'cat' => $current_category->cat_ID // current category ID
);
$the_query = new WP_Query($args);
if($the_query->have_posts()):
while($the_query->have_posts()): $the_query->the_post();
echo '<h2><a href="'.get_the_permalink().'">'.get_the_title().'</a></h2>';
"<p>".the_excerpt()."</p>";
endwhile;
endif;
?>
</ul>
</div>
Related Posts:
- Custom category code not showing all posts
- How to hide posts of a specific custom category in WordPress?
- Display latest post from WordPress Featured Category that is also in X,Y,or Z categories
- Trying to exclude posts from a category on the home page
- Hide empty categories from get_categories
- Exclude a category ID from the following function
- Display featured posts first, then display all others within a specific category in WordPress
- Creating a related post section based on similar categories
- Swapping wp_dropdown_categories function with wp_category_checklist
- Accessing the database from a plugin outside of action hooks
- Echo a hierarchical list of post data from custom fields
- Create WP_Query to search for posts by their categories or their parent/child categories
- WP Query with custom Shortcode
- Best practice for migration friendly images in posts/pages?
- Storing Array from returned database query and using the array in a new query
- Proper syntax or method for keeping url in modified isotope / category links
- Page Automatically Generated from Theme?
- Filter Select results based on selection
- How to add a php custom page to WordPress
- mysql query from wordpress page using custom table
- Sort query_posts for Parent Pages to menue order or the count?
- How to hide all child pages with post_query?
- query in category.php repeats itself
- WordPress 3.2 query_posts and pagination, permalinks issue
- only show container with next/prev links if they exist?
- What is an equivalent of single_cat_title for getting the slug of the category?
- Issue adding sub category programmatically
- What query string parameter is available for index.php, that works for both pages and blog articles?
- ACF: how do I get the fields and its values of a specific group?
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- how do I get a specific post from a post with a subcategory in WP
- WP grandchild categories in nested ul li
- Grab posts by multiple categories
- Pass Category Name, Description and Photo into variables to pass to jQuery
- How to show single category archive
- Move category description below post list in blog
- Set WP_query ‘order’ option by another tables value
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Get page that displays all children of taxonomy parent
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Increase offset while looping
- selected option if current category is the value
- My page.php shows the index.php
- Long running queries
- wpdb php get_var query to get ID for URL image doesn’t work for ID over 999
- get_template_part based upon post’s category
- Populate editor with some content of a page with a page template
- How to pre populate a form field with a link of a current user’s author profile?
- how to save selected option in variable for rest api category filter
- Two queries for a WP_User_Query search work perfectly apart, but not together
- Setting default category base on theme activation
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- How can I add an area/option for a custom page description?
- Create Page To Count Comments For Each Post In WordPress Site
- Different post styles depending on category
- Display category name only once inside loop
- Query if audio attachment AND/OR custom field
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- How to show only subcategories in parent category not parent category?
- register_taxonomy() take much queries
- get_the_title() gets printed out twice
- WordPress SQL injection
- How do I find PHP file that contains content of my page?
- how to show only specific category for a template
- Which is the correct way to conditionally enqueue a CSS file?
- WordPress page content outside WordPress
- Using the_excerpt() on a page
- Inject class in body when particular page template is used
- Dilemma of Populating all the categories in a drop down list
- Odd / Even posts add class minus first post
- Use .php file as page instead of wordpress page & template file?
- Display most popular posts of category
- Use WordPress function in php file
- Creating sub-categories via php
- Define specific category name in PHP
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- unable to use ‘new WP_Query’ in AJAX call
- How to check if the current page is at a specified path in the URL?
- get taxonomy thumbnail and use it as a variable in code
- Include Parent Term in wp_list_categories
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- How to array only one key from another array
- Show About and Contact Us page when they’re clicked in the top menu.
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- How to list commenters and days since last commented
- Parsing Menu Items and Blog Posts
- How to use theme function in post/page?
- How to add div blocks after certain set of post
- Get all categories post is not in
- How to overwrite orderby with add_query_var
- Can’t update multiple rows with $wpdb query