I guess it should work . As long as $id is available things are easy.
<?php
if (empty($items)) {
$ret .= " 'No new videos.'";
$postid = $post->ID; //Supply post-Id here $post->ID.
wp_update_post(array(
'ID' => $postid,
'post_status' => 'draft'
));
}
else
foreach ( $items as $item ) :
?>
Give it a shot.
Related Posts:
- bulk post_content update
- How to check if wp_update_post was successful
- How to integrate blog status?
- Allow users mark posts as “complete”?
- Display success message after wp_update_post
- List taxonomy terms for post as checkboxes
- Count posts by type including drafts and pending posts
- wp_update_post function ignores HTML tags
- Is it possible to cancel a post status transition?
- Enforce conditions only for draft posts using WyPiekacz, ignore pending and published posts
- Check if post was modified by editor different than post author
- wp_update_post does not change post status from draft to publish, returns 1
- How to change post status to draft in Gutenberg?
- Suitable hook when creating, updating and deleting posts programmatically
- WordPress additional update of publications after importing WP All Import Pro
- Turn Off Auto Update for Single Plugin
- Is it bad practice to create own table for a plugin?
- WordPress 5.3 update causes media library file upload to break – Cannot convert undefined or null to object
- What plugins do you commonly install on a fresh WordPress install?
- How to properly insert data into custom table via plugin
- Replacing Icons in the Dashboard
- How to enable edit button in the theme’s customize UI?
- Searching users with WP_List_Table plugin
- Delete Post With No Traffic?
- What is the purpose of adding a .po file?
- Security error WP 4.0 + WP phpBB Bridge [closed]
- Issues creating a tinyMCE plugin that creates a custom link
- How to add a sub menu with AJAX?
- WordPress adding tags into plugin content
- WP plugin management
- What’s the recommended process for organising collaborative posting?
- Is there a plugin that pushes posts to your Google+ profile?
- Execute a function using ajax
- Detecting $_GET parameters from any page + Cookie
- Get userdata inside custom build plugin
- What does do_action() function do in wordpress? [duplicate]
- “Are you sure you want to do this?” when deactivating all plugins in WordPress 4.3.1 [closed]
- how to redirect to my template
- Template for custom post type shows all posts instead of just one
- Is there any multiple filter/criteria plugin for wordpress? [closed]
- How to use different short description in shop page and in product page in woocommerce
- Converting a simple plugin to be placed inside of functions.php
- How to delete terms on plugin deactivate?
- Showing Notifications While Activating Plugin
- Workflow and best practice for documentation [closed]
- Custom routing for plugins
- Difference between register_block_type & wp.blocks.registerBlockType
- How can I filter the contents of a metafield before it’s displayed in the admin?
- register_post_status invisible but searchable
- Can’t create term for product attribute
- How can I get the post content displayed in a text field that allows to edit posts?
- Hidden Custom Post Type
- Is it not recommendable to stick with plugins that are no longer supported by the author for production sites?
- greatest() function returns undefined property
- Is there a way to programmatically enable a plugin?
- Adding Attachment Display Settings in custom media frame
- Conditionally bypass plugin
- How to include code into functions.php file via a plugin
- Override WooCommerce page-specific js in my theme
- Should i delete the posts created by a plugin on uninstall?
- Implement plugins as part of a theme
- Is it possible to install two mail plugins together in a single WordPress site? How to do it? [closed]
- Change sticky status of posts from phpMyAdmin
- Theme or Plugin: Where should I write my code?
- Calling JavaScript file with Custom Plugin
- Convert existing WordPress Site (with several plugins) into Multisite
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- change captcha design in Fast Secure Contact Form plugin
- WP-FB-AutoConnect: Unable to login with administrator account
- Image gallery plugin [closed]
- Where sales manager of WP-Commerce plugin?
- Custom Field Template seriously messed up in WP 3.1.1
- How can I get WordPress to save comments in markdown format?
- Not able to complete meta box save function and sanitization/validation
- Correct way to make meta box with more than one meta field secure
- I want to extend the current themes’ single.php to display the meta fields of my CPT
- How can I implement an Add to Collection function on my Image Gallery to be downloaded later?
- Gravity Forms plugin: How to use “gform_editor_js” action hook? [closed]
- Access WordPress database outside of WordPress
- Prevent WordPress installing plugins and themes via Admin
- Add Piecemaker to WordPress Header
- Filtering out specific post formats from certain pages
- Is there a way to set the default active tab on Post UI Tab pluggin?
- Plugin updates from a specific location
- Calling plugin function inside custom plugin for onclick event
- How to fix wrong attribute error for Visual Composer Grid Builder?
- Show function to super admin
- Generate pages from markdown files in github automatically
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- Setting the profile picture from another field
- Woocommerce Create custom product type with variations
- Shortcode Plugin to dynamically build a shortcode via `do_shortcode` not working
- html generated by theme exist but doesnt appear in browser
- Malicious File Upload [closed]
- dirname( __FILE__) returning wrong directory inside plugin
- How to execute code only on posts older than 2 weeks
- Perform internal redirect in WordPress?
- Using AJAX to generate front end / viewer end pages
- How to prevent plugins from loading jQuery
- How to remove admin main menu name repetition