If you use comma separated id’s in the shortcode like "112,93,34,91"
, you can make use of the explode function to make an array out of the string, like the following:
extract(shortcode_atts(array(
'ids' => ''
), $atts));
$id_array = explode(',', $ids);
Then you just have to use 'post__in' => $id_array
Related Posts:
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Is it possible to create a shortcode that will query a post based on taxonomies?
- WP_Query is printing out only one post when posts_per_page is set to multiple
- Custom Post Type Loop within Shortcode
- wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query
- Shortcode with WP_Query more than once on one page
- Shortcode / WP_Query in post changes context
- Alike Shortcode using in Custom Shortcode
- Modify shortcode to work with custom taxonomies and slugs
- Shortcode display CPT Query only showing 1 post?
- shortcode for recent custom type post
- Adding custom shortcode to page leads to page without styling
- Query by post title
- Get post with multiple meta keys and value
- Get posts for custom post type with WP_Query
- WP_Query() show posts that end later than today
- Sorting a query by custom field date
- Number of pages – multiple (custom) post types
- Enforcing canonical URLs with multiple custom post types
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- Get latest 4 post on a custom post filtered by category
- how to group custom post type posts by custom taxonomy terms
- wp_query and comment_parent – select only posts with top level comments
- Comparing timestamps in meta query doesn’t work
- Include both default and Custom Post Type in query modified inside pre_get_posts
- List all custom post type posts from a given category?
- Using shortcodes to parse POST request (containing the data from a front-end form)
- Exclude current post when getting related post on custom post type and taxonomy
- How to query different post types in specific order?
- Loop on front-page.php
- Custom Post Types not showing, custom WP_Query
- WP_Query | ‘post_type’ doesn’t work
- Filter by custom taxonomy slug on a custom post type
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- Can I create a loop with multiple post types and specify different $args for each post type?
- Shortcode for display posts in wp-editor
- Display Recently Added Custom Post Types with Custom Taxonomy Shortcode
- Display custom post type from dynamic custom field
- Previous/Next Link by Meta Value in CPT
- Custom-Posttype & Custom Taxonomy WP_Query
- Stuck in Order by more then one
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- How do you paginate a query grouped by month?
- Query Custom Post Type Taxonomy term with multiple parameters
- Why is my category template ignoring post type?
- pagination not working for category.php (custom post types in categories)
- Query based on custom fields start and end date
- Retrieve custom post types by custom taxonomies with WP_Query
- Why is my WP Query not returning first result’s post meta?
- Different Limit number of post on different archive page
- DIsplaying URL of custom field in last post of certain taxonomy && post type
- WP_Query Custom Post Type if Category ID Equals
- Custom post types and ‘new WP_Query’
- Using page slug in wp_query
- Custom taxonomy wp_query woes.
- Select2 AJAX and WP Query Returns ALL and does not filter
- WP_Query orderby not work with meta_key
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Different options per post type in WP_Query
- Returning a custom content types with meta values
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- Custom Post type loop with ACF not displaying properly
- Sort results without WP_QUERY?
- Using Wp_Query, Json to add Highcharts series data
- Display the current post in browser as the first post in a loop (for a slideshow)
- Searching post types
- Looking to Customize YouTube Video Embeds
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- wp_query not returning my custom post
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- custom taxonomy pagination 404 error
- wp_query can’t get max_num_pages in custom post type
- Get next and prev item from custom WP_Query and Custom Post Type
- After inserting new post with wp_insert_post() the post is not visble to WP_Query, but the same WP_Query works for post inserted from wp-admin panel
- WP_Query: how to search tags in addition to a custom post type?
- Pagination Not Working When Used With WP_Query() `offset` Property
- How can I use javascript in specific posts without relying on a plugin?
- Help understand and create a loop with WP_query
- WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category
- Search result based on URL
- Shortcode in excerpt
- Imported Content Doesnt Show Up On Frontend
- Loop carousel slider in wordpress
- New WP_Query not isolating custom post types on front-page template
- How to load more custom type posts through AJAX & LOAD MORE POSTS button
- Custom Post Type vs Shortcode: Which one is more performant?
- Pagination always adding “Next” link when results come from Custom Post Type WP_query
- 404 on Pages for Custom Post Type & Query_Posts
- Pagination not working on homepage
- How to query custom post then display sections by meta value
- Using tax_query to get single post per category
- Show Posts in Vertical Tabs with Scrollbar
- How to manage wordpress knowledge base/wiki/posts collections
- Is it possible to make is_category() recursive?
- Get X posts with the same terms as the current post (custom post type and custom taxonomy)
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- How can I show posts with the same tag?
- Load posts via AJAX without draft status
- WP Query – Can’t get posts with specific taxonomy