get_children
returns an array of post objects by default:
https://developer.wordpress.org/reference/functions/get_children/
So you would have to use 'ID' => $child->ID
, in this case… also my want to wrap the foreach with if (count($children) > 0) {}
to prevent possible errors where there are no children. ie:
$children = get_children( $mainid );
if (count($children) > 0) {
foreach ($children as $child){
wp_update_post(
array(
'ID' => $child->ID,
'post_status' => 'wartend',
'post_parent' => $mainid
)
);
}
}
}
Related Posts:
- Replacing textarea with wp_editor
- wp_update_post via ajax from frontend
- How to add correct Last update in Postings (the_modified_time)
- Is there anything like admin_notices for front end?
- How do I fetch the static front page using the REST API?
- How to display TinyMCE without wp_editor()
- Stop/Pause WordPress Heartbeat using Javascript
- get_delete_post_link redirect
- Deleting users from front-end with wp_delete_user()
- add_editor_style is not loading in frontend. Any solution?
- Prevent empty Post Title on form submit via front end post (wp_insert_post_)
- Listing registered scripts
- List custom post types in dropdown
- Saving two categories from two dropdowns in front end posting form
- Modify front-end delete button to publish pending posts
- Not redirecting upon front-end post submission
- Add Media has stopped working in the front end since 4.5 update
- Redirect after successful registration with fronted registration form
- Front-End Editor email notification issue
- wp_editor doesn’t work in front end area
- Frontend tagging for both default and custom post type in wordpress
- Add frontend “Restore” link
- Saving and displaying content on front end with wp_editor
- Why is the Ajax heartbeat included in my cached frontend pages? Is it OK to get rid of it?
- Create front end link to save post (or unpublish post) as draft
- Uploading avatar from the frontend
- frontend user with custom profile pages
- Why is WordPress serving the 1024px version of my image and not the original on a 1920×1080 screen?
- Restrict Login Subscriber users from accessing frontend
- limit file type and file size using media_handle_upload
- RTL/LTR frontend switcher
- Frontend submission upload image via external url
- Delete all children when parent is deleted – frontend
- Preview featured image using frontend post plugin
- Front-end delete account in WordPress
- How to set different languages for front-end and back-end
- How to use WP account on third party module
- Simple reservation system for a card game
- How to display images of a post as a media gallery
- Preview post on frontend before submitting it?
- Add a post with react and axios
- How to set up front end editor to autoembed media for non-logged in users?
- How to do persistent data on Front End?
- Can I use plupload multiple queues in wordpress?
- Frontend image uploading from frontend cant handle hebrew names
- WordPress front-end post form and email after
- br tags on backend not showing up on frontend
- Front-End Custom Taxonomy Tag Select
- Redirect after delete post in Frontend
- wp_update_post is not updating category
- Front end ajax user login session issue
- Why insert post function do not set the modified author without administrator panel?
- WordPress Backend Fine, All Themes Return a Blank Page?
- Excess dependencies
- Create and send a newsletter from the front-end
- Front end post editor which is actively developed
- Get Post ID after front end post submission
- Check for uploaded file type wordpress way for multiple uploads
- “GET / HTTP/1.1” 304 186 “-” inside access_log for a WordPress site, but the admin side works
- Wp_editor doesn’t send the required data
- wp_editor removes HTML and inline styles
- select box not checked and is not saved
- Front end posting
- Front end posting, not working wp_redirect with ‘cannot modify header information’ error
- Front-end registration form with password field
- How to use jQuery(…).material_chip inside WordPress?
- How to upload Web-record Base64 Wave Audio file in WordPress Post (front-end form)
- Frontend registration form doesn’t save data only redirects to wp-login
- Admin Bar – Customizer Label Change
- How to add a new button on post
- Don’t open edit post link in new tab
- How to change custom post order ASC/DESC menu_order wise dynamically?
- Delete post meta front end
- Getting values from database with delay
- WordPress Front end editor
- echo wp_editor to screen with formatting
- upload file with front-end submission and forward the data in an email
- Function working in single.php but not working in custom template file
- updating meta_key from the frontend
- Front end login form not working on live site
- How to update post’s featured image in front-end
- Front End Editor
- Static html/css/javascript front end connected to WordPress
- What is the best way to disabled front-end when using WordPress has headless?
- Remove Unwanted Font Files from Loading into WordPress Frontend
- User Attach Images To Post From Front End
- Putting landing page made with nextjs on wordpress website
- Checkboxes showing on the backend, but not on the frontend?
- Set Featured Image Front Frontend Form
- Creating a multi-file upload form on the front end for attachments
- Uploading video to google drive via frontend [closed]
- How to make the front-end RTL without changing the admin panel language?
- Localization: I want the backend: english and frontend in defined language
- set post author depending on condition via frontend post submit
- Displaying custom content from a plugin within the active theme
- Front End users account with lots of user Roles (not Woocommerce)
- Can you check if https is enabled on frontend from admin
- How to display checkbox meta array values one by one?
- get backend to front end
- Individual Pages are loading halfway down