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
- Search by post title and content in wp_query without order
- Hiding Draft Post In Admin
- Exclude category from
- Blog page not working
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Blog post per page setting conflicting with custom WP_Query?
- Change post order random through out the entire WordPress
- How to insert 2 args into 1 Wp_Query for a slideshow
- How to exclude latest x posts from a paginated query?
- Setup a custom dynamic post
- Anyway to grab author name and featured image in an embeded in inital array of posts outside of loop?
- How to verify wp user password by sql query in wp? [closed]
- Removing noindex posts from wp_query
- How to display the link (title) and thumbnail post?
- Underscores Theme Unit Testing – Catching Untitled Posts
- get_the_excerpt() is not working as expected – returns wrong text
- WP Query – Posts Per Page not working in combination with category__in
- Ajaxify This Code
- 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
- Pausing and Resuming WP_Query results
- How to do set post permalinks using 6 digit random unique function?
- Getting Custom Post Loop to display in Bootstrap 3 column grid
- Select only post id and meta value with WP_Query
- Lost draft under all posts and drafts
- Get user categories with most posts in it
- Unable to restore from backup – how to obtain old blog posts?
- Random ajax load only works with posts_per_page set to -1
- How to : pagination in 3 different custom loops on the same page
- How safe is renovating $wp_query when doing WP_Query pagination in Page Template
- Exclude the first ‘n’ number of posts of a tag from home page?
- Query posts and return XML
- how to change the number of posts returned in a specific loop without making it global?
- Query Posts With Over 1000 Views
- Disable sticky option for specific categories
- posts_per_page option limits the number of Gallery items
- List authors with the last post title and order by last post date
- How to order posts by meta_value and title
- Highlight static blog page link in header
- wp_query random post
- wp_posts table: safely remove unused columns to save database storage
- Query Posts by Custom Field
- Adding a blog archive with pagination using WP_Query
- How to get Tags with specific post id
- Redirect to another page using contact form 7? [closed]
- how can i change WP main archives loop to sort by name or title
- How to create a template for Pages?
- How do I do a page break?
- Using wp_list_pages() after calling query_posts()
- how to get post order by post id wp_query?
- Possible to alternate between two loops
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- How to display all posts divided/ordered by post date? [closed]
- Block editors annoying warnings
- Why Query is returning empty array?
- How do I extract just the post ID of the first item in whatever WP_Query returns?
- Show post content and title in diferent divs using WP_Query using a loop
- Why are my paginated posts always returning the same results?
- Ignore latest two posts
- Is it possible to use WP_Query to only pull posts with attachments?
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- What does WordPress do if I save a post without content/title? [duplicate]
- Adding bootstrap classes to video shortcodes
- Show posts by author of membership level (Paid Membership Pro)
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- add bootstrap post slider with tabs
- meta_value timestamp older than now
- How to add a class to edit_post_link?
- Every second post different class in blog view
- Loop doesn’t exclude the specified category in home page
- Get posts with multiple categories
- Do not show children of a category
- Display posts of specific category term
- Admin – no Featured image choice in create new/page|post
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- Print out last 3 blogposts
- why the same code got different results when using query_posts in functions.php and index.php
- Query posts by Author and/or by Tag
- Query for first 3 posts to change the look and feel
- How to get posts published on the latest date?
- Why posts array is empty?
- Can’t understand why sometimes a [caption] field appears
- WP_Query with custom post type ID
- Page and post loop same template
- Getting blog pagination to work on page set as front page
- How to group only VISIBLE posts? [closed]
- How to check in functions.php if there is data in a WP_Query?
- Shortcode with ‘year’ parameter
- search blog posts by author first name and or last name