You can iterate over the array of IDs and look for the corresponding post in your results to generate output with duplicate posts:
$post_ids = array( 208, 212, 218, 208, 212, 218 );
$args = array(
'post_type' => 'custom_posttyp',
'order_by' => 'post__in',
'post__in' => $post_ids,
);
$the_posts = get_posts( $args );
foreach( $post_ids as $id ){
foreach( $the_posts as $a_post ){
if( $id == $a_post->ID ){
echo get_the_title( $a_post );
}
}
}
Related Posts:
- Get the ID of the latest post
- Sort custom post type list table by display name of a user id stored as post meta value
- Random post, once per day
- Query custom post type by custom field
- Add Custom Post Type to Current Query
- WP insert post PHP function dynamically generated Custom Fields
- Query posts between two dates (custom meta keys) CMB2
- Adding posts of custom type into the main feed
- Inserting data into `post meta` table?
- Custom Select Query with Custom Post Types
- Having trouble with custom date field for CPT query (WordPress)
- Sort posts based on multiple custom fields
- WP_Query search posts by custom post type and custom taxonomy
- Calculating Bayesian average for custom post type
- Show Two custom Post type and their posts on category page
- How to filter custom taxonomy categories on archive?
- Modifying date filter on admin page for custom post type to link to custom field
- Ignore sticky posts if post is not in meta query
- How to debug a blank page?
- query posts and custom post type with meta key
- Use get_post_types to query only custom posts types
- WordPress Orderby Numeric Value Not Working
- Query string parameters from custom fields, inconsistent results
- Custom Post type is being ignored in query
- Query custom post type only if it contains another custom post type
- Add post_type to index.php
- Order By Post Type ThenBy Taxonomy
- Custom query to filter posts that have current post as a taxonomy [closed]
- How to modify archive query with pre_get_posts to append CPTs?
- convert custom query to wp_query
- Search / Filter posts on Title/Content OR Tags
- Get parse_query filter to return slug instead of id
- Querying both pages and posts
- creat filter with wp_query
- First custom field value (out of several) displayed twice after query
- What’s the equivalent of Hide From Menus on MODX on WordPress?
- Displaying Posts from Custom Post Types
- How to organise this data within WordPress
- Custom post type posts don’t show in archive widget
- Showing specific post in order of array wp_query
- Number of posts in the archive
- Query of custom post types only shows first post
- Custom query for custom post_type
- Adding custom field values to wp_list_pages
- How to query 2 custom post types that need to share a slug?
- WP_Query() with custom post type and taxonomy — get all terms?
- Query custom post type based on post id and custom field value
- Listing custom post types on archive page with array
- Can I query posts by taxonomy conditionally based on post type?
- How to conditionally add Custom Post Type to Front Page
- Query not work for current taxonomy
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- Break up posts per page in two sections
- Custom Post Type setup
- Pagination on search results page
- Querying a custom post type, but not show duplicates
- Getting custom post types to properly display alphabetically
- Function to limit number of custom post types on homepage – TwentyTen
- Custom types, taxonomies and query optimization
- Query custom posts from custom taxonomy
- All in one calendar custom post type query doesnt work as expected
- Changing WordPress sort order for returned child pages
- Add custom post type to query
- Query filter by value in meta_value array
- Change search query in wordpress custom post type
- WP Query from two Custom Post type fields as statement
- Using OR relation in meta_query to check for a value before sorting by another
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- Does this archive template part look like its making too many calls to the db?
- Meta query and compare “!=” not working as expected
- Creating a custom WP query for a Custom Post Type
- How select query is generated in a Custom Post Type?
- How to hide sub fields in a field group and also the entire field group if the answer selected is “no”
- post type => ‘any’ not applied my custom queries
- Linking posts together with Advanced Custom Fields “both ways”
- Posts show up under “published” but not “all”
- How do I display specific custom posts, and how do I edit a post’s singular page?
- pagination for a custom query
- Show first posts with custom field not empty and order all by title
- Query Pulling the same post twice
- $post breaking container loop
- Pagination in custom loop for custom post type throwing 404 error
- 404 for children in hierarchical custom post type
- Query child posts on parents single.php?
- Filter CPT based on meta box value using Flexible Posts widget?
- WordPress can only query up to 766
- How would I get a list of posts from a custom post type
- $wpdb returns no results with SELECT query on custom post type, works on default post type
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Allow admin to determine the order of queries?
- WordPress search results
- Code in custom widget queries all posts, when it should only query the current post
- How to add post type in masonry posts elementory widget
- Filter Custom post type by another Custom post type
- Create a list of months based posts
- WordPress Admin Page Slow. Customer Post Type is the slowest
- Add a class to a menu item depending on a body class
- Get Posts ordered by a date custom meta field
- Display all child posts in a custom post type, grouped by a custom taxonomy site
- How can I show a field ID in Elementor with Request Parameter