Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • you must use add post meta data with the key being _thumbnail

    Thread Starter forexfilms.com

    (@forexfilmscom)

    $wp_filetype = wp_check_filetype($filename, null);
    $attachment = array(
    	'post_mime_type' => $wp_filetype['type'],
    	'post_title' => $filename,
    	'post_content' => '',
    	'post_status' => 'inherit'
    );
    
    $attach_id = wp_insert_attachment( $attachment, $thumbnail, $post_id );
    // you must first include the image.php file
    // for the function wp_generate_attachment_metadata() to work
    require_once(ABSPATH . 'wp-admin/includes/image.php');
    $attach_data = wp_generate_attachment_metadata( $attach_id, $thumbnail );
    wp_update_attachment_metadata( $attach_id, $attach_data );
    
    // add featured image to post
    add_post_meta($post_id, '_thumbnail_id', $attach_id);
    Forum: Hacks
    In reply to: cron_schedules

    I don’t think there is any way of doing it without setting a crontab on your server. There is another discussion about doing that in the wordpress support forum.

Viewing 3 replies - 1 through 3 (of 3 total)