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
- Post returns 404 after changing the permalink using post_type_link
- What do ++ and *+ mean?
- How to fix the admin menu margin-top bug in WordPress 5.5?
- Cleaning up WordPress to improve performance?
- How to add date range in woocommerce with code
- How can I modify the permalink via a filter?
- How build a custom login/register form with error handling?
- How can merge two arrays values in one array and save in database
- Network installation giving errors when viewing or adding a user
- Create a post variable processing page
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- List all categories but exclude current post category on single post page
- How Do I Add User Custom Field to REST API Response?
- Bare minimum to include in PHP file to use WP functions? [duplicate]
- Woocommerce, recognize the loop of related products
- Should I store my Facebook access tokens?
- Using FirePHP with WordPress
- How to return output of the new wp gallery block for automatically Link images To Media file
- Can an array be used as a meta_query value?
- WordPress different language footer text
- Filter get_the_title to remove certain characters?
- How do I target the child theme with get_bloginfo();?
- If Meta Checkbox is checked, do something?
- Can I use HTTP POSTs? Is there a better alternative?
- Will simple function names in a class structure conflict with other plugins?
- Image as Sales Badge
- Getting a specific post values to another div or modal
- How can i upload images in an admin page?
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- WP grandchild categories in nested ul li
- Modify HTML structure of fields in woocommerce checkout form
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Limit Widgets to Sidebar ID’s
- How to improve my WordPress filter to include empty custom fields
- Update results, Before deleting the related category [closed]
- Add / Update Custom Fields After Select Pictures in Media Window
- Using Select HTML in Bootstrap Popovers
- Way to add captions to gallery images by code
- Building a WordPress App
- get_template_part for specific page
- proper way to add css using functions.php?
- How do I create my own .php file with a code part and echo it on different pages?
- WordPress Options Page Theory Question
- Help getting previously visited pages ID
- WordPress plugin admin page – using WordPress function in linked php file
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- Cant register rest routs from class instance
- if isset not working for undefined index, how to fix
- Decoded malware code [closed]
- Trying to enqueue script – Nothing Happens
- Undefined offset: 0-wp-includes/meta.php:488 -Melding
- How do I remove duplicate users from two merged WP_User_Query objects?
- calling function in external js file
- How can I get my Media Uploader Button to function on 1 click rather than requiring 2 clicks?
- How to refresh a page from jquery [closed]
- Woocommerce getting top level category parent and make all sub categories have the same template and menu
- Defining multiple categories for showing latest posts
- Pagination Not Working (pages duplicating content)
- Help with accessing wp-admin page and resolving error messages
- Removal of all posts content in bulk, keeping the posts itself
- using shortcodes inside gravity forms
- WordPress template file if else issue
- Trying to update Woocommerce meta values
- ssl redirect function is not working
- Hide specific shipping methode depending on day and time of day
- Adding custom field to product category and show it to shop/category shop page
- REST API custom endpoint to fetch pages and posts not working
- Create “blank” admin page without having admin-bar/admin-menu for faster load
- Export WordPress User Meta to CSV/Excel
- in_array() says array is a bool?
- Check if post visited first time
- Help with preg_replace
- Grouping posts by date
- Store custom field’s multiple values in one user meta key
- Advertisement in Loop Posts wordpress
- WooCommerce multiple custom fields code
- How to display last whole post on the homepage
- How to Pass Current Taxonomy Terms into new WP_Query?
- Pass form attributes to another php template in wordpress
- How to list categories by page id in wordpress
- Resource 404 error on multisite subdirectory install
- WP_Widget dynamic field array with external AJAX
- Passing multiple variables through url (php)
- Programmatically change post templates? [duplicate]
- How to combine array info [closed]
- Select area and checkbox data is not saving?
- Suppress errors when using global function
- In reading settings posts are set to “blog” and I have page-blog.php but no posts
- using a shortcode in a hyperlink
- undefined variable in php
- WordPress move current to top in the loop
- How to change product SKU’s in bulk with a plugin
- BrowserSync not detecting PHP files in WordPress + Laravel Mix
- Function for Post Creation plugin for Gravity Forms
- success Message not Displaying
- child category under correct parent