You can use WP_Query for that :
$contentTypes = explode(',', $_POST['contents']);
$qry = new WP_Query( array(
'post_type' => $contentTypes
));
if( $qry->have_posts() ){
while( $qry->have_posts() ) {
$qry->the_post()
// Your code
}
}
Here is the [docs] ( https://codex.wordpress.org/Class_Reference/WP_Query ) for WP_Query
Related Posts:
- How to get Post Type from the functions.php file
- Replace Post-Title with variable
- How to get all post status
- Permalink like example.com/taxonomy/post_type/postname
- How do I make an HTML table from a database table?
- dbDelta support for FOREIGN KEY
- How can I save a multiple select array with the settings API for a plug-in options page?
- Inject post (from specific category) between posts in Loop
- Place page title in header?
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- Initialize WordPress environment to use in a real cron script
- “wp_enqueue_style();” don’t load new edited style
- Allowed memory size of 268435456 bytes exhausted (tried to allocate 64 bytes)?
- Specified file failed upload test. wp_upload_handle
- Want to separate sections of posts. Can you restart loop?
- How do I create comment-reply-button using element not
- How to Add a Link to the Drop-Down User Menu in the Admin Bar?
- Removing WordPress profile fields from non-admins
- Count number of published posts by type
- Remove username in emails or swap username for email
- Issue with foreach on duplicate meta_key’s
- Why am I getting ERR_NAME_NOT_RESOLVED when I add a site to my multisite installation? [closed]
- Why is ‘admin’ missing from my admin links?
- List of posts by day of the week
- How to add custom taxonomy slug in CPT permalink?
- What SQL / WordPress queries would need a nonce?
- Show custom field if it exists, and show different elements if it doesn’t
- Creating bulk posts with Youtube videos
- How to test nonce with AJAX – Plugin development
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- add_image_size for header_image
- PHP Warning: Attempt to read property “term_id” on bool
- Implementing update_user_meta
- Fatal error: Uncaught Error: Call to undefined function test()
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- Return a numerical function value in Customizer controls
- Passing UTM Parameters To Modify Page In WordPress
- Enable custom logo upload if logo is not in header
- Adding function to Genesis genesis_header [closed]
- theme_root returning a truncated URI
- Echo string and function?
- Only first shortcode gets executed
- What is the latest WordPress that will work on PHP 5.2.17?
- Get all categories post is not in
- Function returns post URLs rather than retrieving Facebook Graph API data
- Error while setting role
- Editing a PHP file to include a small text piece on every page
- How to disable send e-mail notification new comments for some posts
- trying to put an active hover to my custom nav category buttons [closed]
- Can’t successfully check if post with title exist in database
- Handling repeater data
- Adding Updated Post Date PHP Custom Theme
- Filter results from a serialized string to use on statistics
- Create a a form for custom taxonomy terms
- form built dynamically with php, not submitting
- Post to WordPress from another Server via PHP
- How to make blog post entries appear as input form instead of just text?
- If is page, archive or search output this code
- Child Theme’s Read More Text
- What is the difference between Null vs Empty (Zero Length) string?
- Get date function not working
- WP_Query – How to query all of post types categories
- How to work Woocommerce pagination inside shortcode?
- Trying to add Custom Post Type to this functions.php command
- Apply function.php filter only if url not has /amp/
- ACF Taxonomy field values not select in backend
- Place product field value as variable in php
- Wp-query output correct, but the loop shows one less item (only sometimes)
- Get list of posts from attachment
- Refresh page after login with litespeed cache
- The plugin generated 225 characters of unexpected output during activation
- Call jQuery function from PHP?
- remove_action() not working in page template – Genesis
- Adding action item to admin users table and sending email
- Metabox – Displaying the Value of a Metabox
- Using get_the_excerpt in edit-post
- Create dynamic content from one WP page to multiple other pages
- ajax form with multiple submit buttons and values
- Unserializeing multiple column values that are stored in one database results variable
- WordPress – custom navigation item classes
- Is there a way to randomize and connect a background and header image?
- Post Thumbnail on Single (if elseif else)
- Keeps asking Connection Information upon update to 3.5.1 (but not for plugins?)
- How can I add more code to this?
- Sidebar doesnt get updated?
- Edit the Publish Widget Options
- Display custom meta box in my template file
- wp_enqueue_style conflict when using in different action hooks
- WordPress developer
- If the_content’s string length is greater than 0, show post otherwise dont
- WordPress post pagination on custom template not working
- get_option(‘admin_email’) not working in wordpress when using ajax call
- How do I update product shipping using PHP in WooCommerce?
- Front-end major break after upgrade PHP 8.0 [closed]
- wp_enqueue_scripts with JS script as a string
- Why can’t I enter the wordpress admin interface?
- base64_encode conflict with convert_smilies in wordpress
- Edit Error Page style
- How to sort wordpress posts by selecting a year from a drop down?
- How can I use AJAX in child theme template?