• Open simple-post-expiration.php

    Replace Line 84 to end, to this instead:

    /**
    * Filters the post titles
     *
     * @access public
     * @since 1.0
     * @return void
    */
    function pw_spe_filter_title( $title = '', $post_id = 0 ) {
    
            if( pw_spe_is_expired( $post_id ) ) {
    
                // Post is expired so attach the prefix
                $prefix = get_option( 'pw_spe_prefix', __( 'Expired:', 'pw-spe' ) );
                $title  = $prefix . ' ' . $title;
    
                //Change Post post_status
                wp_update_post(array(
                    'ID'    =>  $post_id,
                    'post_status'   =>  'draft'
                ));
    
            }
    
        return $title;
    
    }
    add_filter( 'the_title', 'pw_spe_filter_title', 100, 2 );

    Changes post to Draft when expired

    • This topic was modified 3 years, 7 months ago by samjco.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter samjco

    (@samjco)

    Hey Pippin!

    What are you using to automate the detection and change?
    Post, plugin load or cron?

    Plugin Author Pippin Williamson

    (@mordauk)

    I’d recommend setting up a cron job that looks for expired posts and updates them. Once per day should be fine.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Changing Status when expired’ is closed to new replies.