Can I edit listing in bulk to renew ad which are expired?

Discussion in 'ClassiCraft WordPress Theme' started by eurekaweb, Jun 6, 2014.

  1. eurekaweb

    eurekaweb New Member

    Joined:
    Nov 26, 2013
    Messages:
    11
    Likes Received:
    0
    I have started listing from few days and so far some ads I am seeing are already expired. How can I edit those expired ads in bulk to renew them together? Thanks in advance for your outstanding help
     
  2. Gourav

    Gourav Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    7,728
    Likes Received:
    207
    Hello,

    Go to functions.php present in your theme directory and add the code given below
    Code:
    global $wpdb;
    $data="SELECT * FROM wp_posts WHERE post_status = 'draft'";
    $queries = $wpdb->get_results($data);
    foreach ($queries as $query) {
    echo $post_id=$query->ID;
    $meta_key='cc_listing_duration';
    $post_status='post_status';
    $posttable='wp_posts';
    $meta_value='08/20/2015 07:15:45';
    update_post_meta($post_id, $meta_key, $meta_value);
    $wpdb->update($posttable,array($post_status =>'publish'), array( 'ID' =>$post_id ),array('%s'),array( '%d' ));
    } 
    "$meta_value" defines as the date at which you want to expire your listing, So fill "$meta_value" as per your requirements.
    Firstly save that code in the bottom of function.php file and then refresh your dashboard and website, It will activate your all ads after that remove that code and again save your file.
    Thanks & Regards
    Gourav Shrivastava
     

Share This Page