Support

Account

Home Forums ACF PRO Expire Posts on Datepicker Field Reply To: Expire Posts on Datepicker Field

  • Hi @precisioncreations

    Thank’s for your example too. It’s pretty much the same as mine except you also run a transient check so as to avoid running it more than once a minute (I’m guessing?).

    A few key differences tho I think worth mentioning is:
    1. Always use WP_Query if you can. get_posts() is a wrapper for WP_Query which excludes filters. It’s just good practice tho, don’t think it has any real impact on load times.
    2. By using wp_transition_post_statusinstead of wp_update_post we only update the status column in wp_posts table. The benefit of this is that it only handles the status so it’s faster and also it wont trigger any save_post hooked functions.