rule of thumb, never do anything that results in DB write from the front end. Even better if you can create an admin page in which the operation is triggered (even if it just starts an AJAx based process).
Your problem here is with hooking on an inappropriate hook. You hooked on init
which means that for each request the code to change all your posts is being run. Since this is a heavy operation it overloaded you DB and therefor your server. I am not sure why cron was singled out here.
As an additional note, your save handler is not great, you should make sure you are handling the post type you want and not revisions or auto saves.
Related Posts:
- Organizing Code in your WordPress Theme's functions.php File?
- How to check if a user is in a specific role?
- Can’t change language (only “English (United States)”)
- How can we make managing lots of pages in WordPress Admin better?
- Create WP tutorial for users with admin pointer using next button for navigation
- Taxonomy dropdown metabox in the back-end
- How to redirect/rewrite all /wp-login requests
- Show all post tags on post edit screen/sidebox
- Add “external” link to admin menu in the backend
- How can I enable Google Analytics on a file download link?
- What is the best method to close off the backend?
- Change Login URL Without Plugin
- Pre-fill fields with content from outside when creating a new post
- Why are admin scripts not printed
- White screen of death only in wp-admin
- Change the link of ‘Howdy’ at the top right
- wp-admin pages return ERR_EMPTY_RESPONSE
- wp-admin remove the subfolder URL
- Reorder custom submenu item
- Options for restricting access to wp-admin
- Unwanted redirect in admin area
- Removing admin bar from wordpress dashboard
- Load Balanced WP with single server admin access
- How to move wp-admin login page to another location? [closed]
- WP-admin giving 404
- File exceeds upload_max_filesize, despite max filesize being large enough
- WordPress admin not changing language
- Can’t access dashboard, connection times out (other pages work fine)
- Getting post meta data, while editing a post in wp-admin panel [closed]
- Deprecated : contextual_help has been deprecated since version 3.3.0
- Change WP-Login or WP-Admin
- Custom roles showing HTML entities in title form field
- WordPress address URL keeps dropping the www
- How to show postmeta in custom columns for the posts screen?
- wp_nonce_url to users.php for deleting user not working
- How can I remove the user avatar from admin toolbar?
- How to stop – Database Update Required – from happening again?
- Moving wp-admin to a different to a subdomain
- using wp_sprintf at wordpress option page,
- Not Found (404) error on admin page, CSS gone on blog
- MySQL CPU Usage Surge up When Multiple Post Editor Pages are open
- Remove All in One Pack from the admin bar
- Post Editor not working on WordPress 3.5.1
- How to Change The WordPress Login URL Without Plugin
- Disable wordpress reordering functions in backend screen element
- transition_post_status not working via Quick Edit
- how to customize wp-admin page using child theme
- Enque script based on url paramater
- new subdomain to apply as main domain
- How to disable admin notice in child theme? [closed]
- WordPress server change – slow admin login time for first time
- Ajax solution similar to WP Categories functioning in Admin area
- How to get specific page screen ID
- Hooks: admin_footer and admin_print_footer_scripts not working?
- Hide admin menu on update_option
- Editing edit-tags.php page in wp-admin
- What is the correct way to get only display plugin for Administrator Only
- displaying an error before update_post_meta
- firing function at login within class
- Browse Happy in 3.2
- How to break line / add to ADMIN menu
- Adding Notification Bubble on Admin Top Bar
- WordPress admin page not found error
- Outputting something based on the presence of post variable in admin screens
- Registering for a domain on WordPress
- WordPress site stopped working after simply opening header.php in the wp-admin editor
- User Profile Avatars
- Ajax requests from front-end with jQuery Fancybox
- Dismiss Admin Pointer Temporarily
- Why wp redirects me to wp-login.php when I visit a rewritten wp-admin URL?
- WordPress menu to change page title
- Performance-issue in WP-admin with a lot of posts
- Disable some features in Admin
- Updated MAMP and localhost on MacOS site no longer accessible
- Don’t run code if in customizer or privew
- Redirect WordPress login for customers but not admin
- Function to get a ‘post selector’ UI?
- Unable to open specific posts on WP Dashboard [duplicate]
- How to list newly ftp added HTML webpage under Pages section of wp-admin?
- Hi everyone, I have Problem with using wp_die()
- WordPress wp-admin Page
- CSRF attack to create USER
- Disable flyout (popup) menus in backend
- Changing headers for an export from within a PHP class extension
- When installing wordpress through WP CLI mysite.com/admin not working
- Remove capability to interact with a page
- Random HTTPs redirections at admin area in shared hosting
- How do I change the WordPress Address URL only and still login to wp-admin
- wordpress wp-admin showing white screen with no error
- Undeletable posts, users or other content
- Making changes to woocommerce order before save
- Blank sign in page
- add_post_meta displays in admin edit area
- Forcing WordPress Administration onto a separate SSL Host
- How to prevent Google adsense invalid impressions while performing admin tasks on my wordpress site?
- What is the point of new confirm admin email process?
- ‘Too many redirects’ error after changing site URL in WordPress [closed]
- Couple questions about .htaccess, login page, updates
- Is it possible to tell if a user is logged into WordPress from looking at the cookies which are set?
- Https Website: CSS and JS files load in http and admin page does not load too