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
- How to add a .php file to WordPress
- The correct method to pass query vars in AJAX using ajaxurl
- How to check if feed URL was requested?
- Alter query on edit.php
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- How to find objects by terms
- How to create a WP_Query to search the Title or Tag?
- How to Populate the list of custom post type categories
- Php string not working in WordPress Functions.php [duplicate]
- How to get user by display_name with WP_User_Query
- User Defined order on get_categories?
- Categories Template Assistance
- Get only the grandchildren, not the direct children of page/current page?
- Problems with function on function.php
- Use template for posts with a particular category grandparent
- How to get to a specific position in wp_query?
- in_category() works in single.php but not in page.php?
- Get all user meta by meta key instead of ID
- Can’t get page content in WordPress
- Best practice for migration friendly images in posts/pages?
- Page Automatically Generated from Theme?
- mysql query from wordpress page using custom table
- How to hide all child pages with post_query?
- What is an equivalent of single_cat_title for getting the slug of the category?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Move category description below post list in blog
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Populate editor with some content of a page with a page template
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Let Users Choose Post Categories
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Using the_excerpt() on a page
- Display most popular posts of category
- get taxonomy thumbnail and use it as a variable in code
- How to use theme function in post/page?
- My php code is not being executed
- Apply class to every third list item? [duplicate]
- How to include custom code on a page that’s set to act as homepage?
- Can a page contain php code?
- working with term_relationships table
- Insert page content into another page with a changed variable
- Use get() method to grab all categories and output inside another method
- Only show size attributes in product box woocommerce when available
- Argument for if term-> have child?
- Shortcode to pull posts
- Displaying list of posts in category page
- How to add page numbering with php?
- Echoing a CSS class based on category of post in a list
- Noindex subscriber author page
- Undefined variable: row?
- Showing Subcategory Name/Link Instead of Parent Category
- WordPress custom taxonomy
- custom query for both category and pages using global $wpdb;
- Finding and removing duplicates within WP Arrays
- Compare current post Category in select menu
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- WordPress is removing query variables like page, p from the URL of a custom static page
- Get the list of post categories
- WordPress Conditional / Multiple Taxonomy Query
- Pagination at category doesnt work with same name of page
- Woocommerce. Get a list of products in the current category on the archive page and product page
- How to show categories and date on posts
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Allow two posts (from different categories) to have the same slug
- Child-Theme Category View with modified permalinks (%category% removed)
- How to move a post from one category to another
- Create category after theme setup and modify the default one
- Let user select the number of posts shown per page jquery error
- How to query a staging database?
- Displaying 3 Category Posts differently
- How to list categories by page id in wordpress
- Include a custom field in mysql query
- WordPress using get_term to retreive slug not working as expected
- Showing the project type in HREF
- How do I display Category titles on a WP Page?
- Front end post submissions do not get submitted in the category
- Replace content in WordPress Page after GET from php page
- List of child pages fetch next results at link click
- How to use PHP code with wordpress page
- Saving category as insert post
- Check if values exists DB
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- get_category only returning details for ‘uncategorized’
- Trying to put a search page on site
- The search engine of my website finds only posts and not pages, how can I solve this problem?
- Hide page title
- I can’t seem to get excerpts showing inside get_pages and don’t know why?
- Query Concatenation
- on category page get name of category as a string
- WordPress categories not working throughout site
- Remove /category/ from category (archive) page URLs (without using a plugin)
- Get Products within Current Product Category
- hello can you advise how to fix the error?
- Sorting a custom post type in pre_get_posts