You can do it by manipulating the WP_Query
arguments like below-
$idObj = get_category_by_slug('water-pumps-modal');
$args1 = array(
'post_type' => 'post',
/*'category_name' => 'modal',*/
'category__in' => array( $idObj->term_id ), // Take only IDs of the categories
'posts_per_page' => '1',
);
Related Posts:
- How to know if get_posts() failed?
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- Why won’t my taxonomy query show up?
- how to handle the loop using filling bootstrap grid structure?
- Order posts inside bootstrap card columns
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- How to show the posts list into a static page? Problems to use the loop into a static page
- Wp_query WooCommerce products
- Get posts after calculating meta key
- Adding additional data to WP_Post object
- WP_Query: Why is sticky post not first item in loop?
- Displaying the category name of a custom post type
- How do I reorder (pop and push) items from WP_Query?
- How to exclude latest x posts from a paginated query?
- How do I sort (order) the results from `get_children()`?
- Reverse chronology of post listing
- Most viewed post for the last 2 days using WP_Query
- Adding Post Counts to Menu (Nav) Programmatically?
- how to display full post with pagination on home page
- This AJAX Code Doesn’t Work – Looking for elegant solution
- How to add posts to wp_query result?
- Posts for next month
- WP_Query only ONE post, won’t work
- Replace Main Query With Custom Query
- Hide Post comments when displayed via WP_Query
- Group posts by year in loop
- wp query with dynamic taxonomies and terms?
- How to get posts by multiple post slugs? [duplicate]
- Changing next and previous post link text
- Blogroll – Different layout for first post
- WP_Query: offset ignored when posts_per_page is -1?
- How do I use `posts_distinct` correctly?
- How can I remove posts of a certain category from homepage after a specified time period?
- Automatic value for custom fields for posts
- Loop through all product posts?
- Get random posts between specific dates / of specific age
- How to find what index page a post is on?
- Get Posts that are in the current month or later
- WP Query to Get Array of Slugs
- How can I sort posts by the date and a custom meta field?
- Hiding Draft Post In Admin
- How to verify wp user password by sql query in wp? [closed]
- How to use format post in a pertinent way
- How to filter my search in post if contains a word in title, content or excerpt?
- How to return another post than requested
- Lost draft under all posts and drafts
- Get user categories with most posts in it
- Random ajax load only works with posts_per_page set to -1
- Query Posts With Over 1000 Views
- List authors with the last post title and order by last post date
- How to order posts by meta_value and title
- Adding a blog archive with pagination using WP_Query
- How to get Tags with specific post id
- How to create a template for Pages?
- How do I do a page break?
- WordPress query_posts by tag doesn’t work anymore(?)
- Ignore latest two posts
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- add bootstrap post slider with tabs
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- Print out last 3 blogposts
- How to group only VISIBLE posts? [closed]
- Shortcode with ‘year’ parameter
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- On what hook can I get the queried object’s final state?
- How can I insert a new markup element after 4 posts automatically? [closed]
- Give posts a particular template based on the assigned category
- Get all custom posts with a certain taxonomy
- Link to date_query results in WordPress
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- Limiting post list by taxonomy
- How to display WP Query filters?
- Finding a post’s slug
- Am getting duplicate data from get_posts()
- Change modified date to current date when title updated automatically
- How do I display main query posts in random order using add_filter
- Aligning images in the wp editor not working. How do i get this to work in custom theme?
- Function is printing twice – any suggestions?
- query posts with selected post ids first
- How to use two query result together in one loop
- show loop id post , only first id can read
- filter posts based on menu_order
- Change archive results based on GET request
- wp_query args with relation
- Wp_query loop is not working as it should
- Show all posts from the tags without having to set all of them
- Display post order ranking within wordpress loop
- Creating Ordered Query using Meta_key
- WP Query between posts custom fields [duplicate]
- Retrieve latest post by multiple categories with ID
- Update Post with Modified Data
- How to Include a common category in a custom Category Search
- wp_query select if have comments
- wp_query posts sorting doesn’t work
- Order by ‘s’ using WP_Query()
- custom sort posts in archive/taxanomy page
- how to print loops for odd in 1st column and even in 2nd column in wordpress [closed]
- Trying to create shortcode listing custom posts, but formating not being included
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- Next and Previous buttons are not showing on home page for post