The problem I can immediately see is, you’ve set:
'post_status' => 'published'
This should be:
'post_status' => 'publish'
Also, since you are only updating the post status, it’s less error prone and more appropriate to use wp_publish_post
function instead of wp_update_post
function.
With this change, your karma_approve_all_posts()
function will look like this:
function karma_approve_all_posts( $posts ) {
if( count( $posts ) > 0 ) {
foreach ( $posts as $post ) {
update_post_meta( $post->ID, 'approve', 'approved' );
wp_publish_post( $post->ID );
}
}
?>
<div id="message" class="updated notice is-dismissible">
<p>All posts have been approved and published.</p>
</div>
<?php
}
Related Posts:
- How to change post status in hook?
- How to trap “Publish” button to check for meta box validation?
- wp_update_post deletes post meta in CPT
- Add Password Generator on password protected page
- $wpdb->update() always need a second try
- WordPress publish_post hook not getting featured image and meta on first publish, but works on updating title
- Set page to draft on plugin deactivation
- problem with blank page
- Tracing dashboard publish settings from input form in WordPress
- Plugin SVN folder structure
- How do i best handle custom plugin page actions?
- Automatically determine minimum WordPress version required for a plugin?
- Create a custom admin page for custom post type + taxonomies + metas
- Is There A Hook To Process The Content Of The Text Widget?
- Enqueue script only when shortcode is used, with WP Plugin Boilerplate
- add_filter OO with parameters
- Preferred way to include Advanced Custom Fields in a plugin?
- How to link to images in my plugin regardless of the plugin folder’s name
- ERROR: Options page not found – saving settings page with tabs
- Can I leave out `if ( ! defined …)` when defining plugin constants?
- Using the component outside the editor. select(‘core’) is null
- Gutenberg is there a way to know if the current block is reusable?
- Any ideas how to make unit test read the theme functions.php?
- WordPress Ajax callback function from plugin – OOP
- Is there any way to have Featured Text, as opposed to Featured Image?
- StackExchange clone using WordPress?
- Custom url for a plugin page add_rewrite_rule WordPress
- Custom attribute type not displaying terms in edit product – WooCommerce
- How do I add a prefix when a user registers
- Verify if user is wordpress logged in from another app since wordpress 4.0
- how to get link of added document with a post
- Doubts about the use of metadata and how this can affect performance on WordPress
- How can I replace content in the WP Admin area before an admin page is rendered?
- update_post_meta not working in a loop
- When is the proper time to minify css and js with git workflow?
- Get draggable widgets on Edit Post page
- Plugin that saves form data
- how to invoke wordpress API from other existing PHP system
- Warning: include(): https:// wrapper is disabled in the server configuration by allow_url_include=0
- How to get the post excerpt using post object?
- jquery & ajax sending data to php
- How to import the css in the plugin admin area?
- How to get the url of logo image?
- Replace first occurence of a word with link [closed]
- Converting core modification to a plugin
- wordpress automatic update does not run
- Adding filter to the title without affecting the menu title
- How to show multiple instances of the WP125 Widget?
- How can the_excerpt (or equivalent) be called on a category description?
- Plugin Creation: Overriding upload_max_size and post_max_size
- How to call a function from a shortcode function in an oop plugin
- How to access index file in Block Themes?
- Multiple TinyMCE on button click is initialized and appended but why only last one is writeable?
- How to create a custom post-new.php page for plugin , no wp menu
- How to create a custom WordPress page with my plugin?
- Want to know how to reveal a WordPress theme, considering the theme name is hidden?
- Where to add functions and code snippets in wordpress
- How to re-render inspector controls?
- Sanitize WordPress Array Input?
- Shortcode content is not showing. Only the [shortcode-tag] is showing
- How to remove the WooCommerce Product->Category thumbnail from admin [closed]
- Is it possible to replace MySQL with JSON files for WordPress
- Creating a virtual page without exit
- Plugin Development – Call to undefined function comment_exists()
- Replace “content-area” of themes 404 page with plugin?
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- WordPress doesn’t create table on plugin activation
- Create Customization panel for Plugins not for theme
- How is construct function working even when variable is assigned null value?
- Custom signature appears twice on page
- Declaring a new woo commerce product type i get this error
- wp_mail links are dead
- List Available Templates for Current Theme in a Plugin
- Adding Third Post Box Column: postbox-container-3
- Is it safe to use PUT and DELETE requests
- WooCommerce custom payment gateway
- Multi-part form and wp_redirect()
- Sharing changes to a post (preview changes) with another user
- Checking if the query is empty does not work
- Remove default wordpress roles
- What is the meta_query key name for the woo product average rating? [closed]
- how to catch a data from a array in WordPress
- get the queried_object of an url
- Advanced Custom Fields conflicting with custom plugin when saving custom field
- Need someone to help you want to manage points for members to code interface functions? thank you
- Call API on post save/update and show the result in admin area
- Is there any other ways to replicating changes on live from staging without pushing from git
- Why my admin-ajax url returns 0 even after adding echo and die() at the end of function?
- External api call using wordpress
- Set link dialog to open in blank by default
- plugabble wp_authenticate function not works from wp-login.php
- How to get recent one post from each category on home page?
- How to get custom user meta by id in custom Gutenberg block
- How to prepend a header section to all pages related to my WordPress Plugin
- How to access Elementor-navigation-elements via jQuery
- Hook a search form anywhere on the site, using a custom plugin
- Plugin forms overwrite each other’s options
- ACF – programmatically install and activate in pipeline to automate testing for custom plugin development?
- How can I include React useState in a custom gutenberg block plugin?
- Problem with Owl Carousel, infinite loop [closed]