I find-out an way, when working on a cron related project.
1. Install and active [WP Crontol plugin][1]
2. Go to Tools->Cron Events.
3. Create new cron job at `Add PHP Cron Event tab. Here, I use PHP code
global $wpdb;
$posts_table = $wpdb->prefix . 'posts';
$term_relationships_table = $wpdb->prefix . 'term_relationships';
$postmeta_table = $wpdb->prefix . 'postmeta';
$sql = "DELETE a, b, c
FROM $posts_table a
LEFT JOIN $term_relationships_table b ON (a.ID = b.object_id)
LEFT JOIN $postmeta_table c ON (a.ID = c.post_id)
WHERE a.post_type="post"
AND DATEDIFF( NOW(), a.post_date) > 365
";
$wpdb->query( $wpdb->prepare($sql) );
now and 12:00:00 in Next Run
Once Hourly in Recurrence
- Save this cron event and click on run now.
Related Posts:
- How to export comments in WordPress?
- How can I call a function from one plugin within another plugin?
- Gutenberg disallow certain custom blocks but keep all core blocks?
- Publish author posts only with editor approval?
- Customizing subject in comment notification e-mails
- WP showing “warning: call_user_func_array()”, What to do?
- Declare a function before plugin does on the theme functions.php file
- Generate Advanced Custom Fields box in custom admin menu page
- Removing user contact methods works from functions.php but not from a plugin
- While Using Static Pages, How Can I Get /blog into the URL of Each Post?
- Use functionality of 2 wordpress plugins
- What’s the point of using WordPress’s built in admin-ajax.php?
- How can i change an image’s author?
- Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory
- Showing Co-Authors on post page
- jQuery Plugin to use WordPress functions in AJAX request
- Using plugin functionality in external php script not working
- Debugging Technique Question re: functions.php
- Override plugin with functions.php
- WP Job Manager Category Drop-down; Change Placeholder Text Via Filter
- Custom Taxonomy Tag Search
- Missing argument 3 for wp_register_sidebar_widget()
- Redeclare theme’s function in a plugin
- I have functions in my wordpress plugin. How do I get them to work for me?
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Shortcode button dosent work for all posts. Work for first post only
- Is there a way I can find wordpress posts that don’t contain a word?
- Prevent shortcode from being wrapped in tags
- Change wordpress current_time function to different timezone
- How to override a plugin function wrapped in a class?
- Edit Yoast SEO breadcrumbs output [closed]
- Snippets: is it better to add them in functions.php or make site-specific plugins?
- Using a post-signup hook to get user details
- Restrict media upload size by format
- Facebook Messager Plugin
- All sites themes functions.php have been changed
- Grab WordPress Salt Data From URL
- WordPress get_avatar function not correct working
- WordPress metaboxes – textfield suggestion automatically populated
- Which file of wordpress manage plugins functionalities?
- Improving the perfomance of a plugin action
- Check if variable is set in filter
- Image change on hover
- Passing stored variables to add_filter
- JQuery prepend a function
- Why can’t I call a (member) function from within a foreach?
- Shortcode Attributes to Return different $_POST
- How to make a dynamic css class whose name changes every visit to confuse scraper
- Send email with list of active plugins upon activation/deactivation
- Using custom fields for image alt and title
- Where Should i write the code for wordpress ajax voting?
- Set up functions to be overridden without using function_exists() by short-circuiting them?
- WordPress function to add text warning on every pages [closed]
- How do I convert my WordPress website to be domain agnostic?
- Add the_post_thumbnail_url to a shortcode in function.php
- Add action to custom Function
- Show media-uploads to all users
- Help with a function in a widget
- how can authors to define custom pages?
- Adding a Tag Parameter / Filter to My Shortcode
- How do I create pages within a WordPress post?
- How to upload large media file in chunks, without any plugin?
- Allow a particular user to access a particular plugin?
- WP Function does not trigger on Webhook API Call
- Why do I need to reload the page for WordPress to see the new custom field added with jQuery
- Cookie value changes back to previous value after changing
- RSS Feed on WordPress showing code (hypertext) in articles titles
- Alternative Hook to the_content for Changing Background Color
- Unpublished Pages Failing To Appear On Custom Path
- Post source link plugin – small modification
- How to add specific script to WordPress webpage that will working with user input and databases
- Hide Plugin Custom Post Type Menu Link
- How to create algorithm for ordering posts in WordPress?
- Add external javascript to post template
- Block plugin update possibilities (but not by hiding notifications)
- Execute function activate/deactivate plugin in specific pages
- Securing langugae folder
- Plugin function in child theme
- Return function results within shortcode
- Soflyy WP All Import Custom File Download Issue
- Update (a function) post’s featured image as soon as $image_url changes
- How to Call Function From Separate WordPress Install on Same Server?
- How to echo a plugin’s function into a template?
- Find all strings between an enclosing shortcode
- Wp Ecommerce Reposition Product Page Product Thumbnail Image
- It possible to implement an adhoc php web application with wordpress?
- How to Overwrite validate_plugin function
- making a glossary with wordpress
- date function not correctly returning date
- Disable plugin function
- Access to wordpress method inside of classes
- How to prevent page load on form submission
- wordpress Search function is not working
- Send email notification when meet the condition
- WordPress: code structure
- PHP Creating a formula from mysql db values and db stored math operator
- filter just a portion of plugin function
- Sort posts by Date (DESC) and by ACF: active_inactive (ASC)
- stop resize button for wordpress media
- Mixed results with is_page() WordPress function, when using $this, or self