What you are doing is the safe way, and the way I’d recommend. To my knowledge, there is no Core function to bulk update only single values in the $wpdb->posts
table, so to do that you’d need to write your own SQL…
$ids = array(); // your IDs; I am assuming these to be validated and sanitized
$wpdb->query("UPDATE {$wpdb->posts} SET post_status="publish" WHERE ID IN (".implode(',',$ids)).")");
You might be able to do the same with $wpdb->update
but I rarely use that method, so I am not sure. (A comment below indicates that it is not possible.) Check the Codex and play with it if you want.
I would recommend not doing either, though, and continuing to use wp_update_post
. If you skip around the Core functions you also skip around numerous actions and filters, and may cause yourself unintended consequences or other frustrations later on.
Related Posts:
- How to add a button to custom post type’s posts-page
- wordpress remove views from action links in a custom post
- Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin
- Is it possible to get the specific content on the search page?
- Create a post automatically if search result has zero results
- Correct way adding External classes to Custom Post type and output their methods to template
- Widget area for individual posts (custom post type)?
- call a function when insert and update a custom post type
- How to change post cpt with submit button?
- Remove slug from custom post type post URLs
- How to get post content by calling ajax?
- Get category id from post id of a custom post type
- How to add custom content template part for a custom post type on main query using a plugin
- Limit widget to a specific registered sidebar
- WP_List_Table Inside Metabox Not Working on Submit
- wordpress plugin error handling
- How to get term link that crosses different custom post types?
- Where to put archive-{post-type}.php
- Showing current taxonomy terms
- Determine which template-{slug}.php is being loaded
- Newer/Older posts links display same posts on every page
- custom sortable column
- How to embed form data within the ‘Add new post’
- Remove POST_TYPE from custom post type permalink
- When viewing single parent post, display list of children
- Limit Authors to their Own Posts on front-end excluding admins
- Remove Post Page “View Post” Link
- Make custom post type display as a page
- Get all posts WHERE custom_field is LIKE value
- How to rename image at uploading on specific plugin or post-type in WordPress
- Loop on front-page.php
- Custom Post Type Navigation on Custom Field
- Plugin translation not working apart from name and description
- How to create custom boxes with text inside?
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Custom posts don’t work
- How to customize a permalink (URL) structure?
- Disable block with taxonomies at post page
- Which post does a taxonomy term belongs to?
- Changing custom type name hides the posts
- Add custom field to Posts and sort by it
- Update post meta not working in transition_post_status
- Two Custom Post Types Many to Many Relationship
- Problem with displaying posts in the CPT category
- How to change the post type a theme shows by default?
- No Permission to add new Page, Post or CPT with Admin role
- Update postmeta Parent when post_status child change
- Custom post type archive page blank
- Custom post listing page layout of custom post type
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- 2 Different Custom Post Types in Submenu
- How to assign classes to all elements?
- Wrap meta boxes & data handling for specific post types in classes?
- Reworking function for counting custom post type posts count
- help
- WordPress custom post type capabilities issue
- HowTo: Custom Post Type (Meta) to Custom Table
- Custom Empty Results page for my Custom Post Type
- How to group navigation items in the admin panel
- Showing custom post type categories in the menu
- How can I include active content in a custom post type?
- ajax response not recieving
- Dynamic pages for linked categories and content
- Separate Content from gallery (custom post type)
- How to set the mainpage of a custom post type?
- CPT to installable Plugin
- Fill custom fields when saving custom post types
- Does “Custom Post Type” can have page hierarhy option?
- A sports wordpress website
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Custom post category name showing empty
- Get next and prev item from custom WP_Query and Custom Post Type
- How to mass get post editor URLs
- Error 404 change permalink term custom term taxonomy
- Show a custom post title in another custom post type in Meta box
- Register custom_post_type from static function
- how to display posts content on the custom css popup by clicking on each title on the sidebar?
- How to select meta key in custom database query
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- Restrict Custom Post Type to One Item
- How to create editable sections in wordpress?
- Instructor can view, edit, delete only theirs courses
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- subtracting the current post form then whole loop, which is generating all CPT titles
- Custom post type that lets users create a set of posts?
- Show custom post type under last posts configuration
- How to develop custom URL redirection
- Execute code only after user clicks ‘update’ button for CPT being edited
- Can the wp_posts table have the same slug (post_name) in multiple statuses (post_status)?
- Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update
- Add category slug as class attribute in a link array
- Custom Post Type used for FAQs Accordion
- How to Associate Posts with Pages
- Custom post types working in functions.php but not in plugin
- delete custom post type using a submit form
- Why are my wp urls showing page not found?
- Post content stays the same but permalink changes ?
- Can I set a CPT title field to a dropdown with preset options if user is of a given type?
- How do I display the index position of a post from a custom post type?
- Sort ACF by custom taxonomy