WordPress.org

Support

Support » Plugins and Hacks » Keyring Social Importers » [Resolved] Setting a featured image for all posts imported from Twitter?

[Resolved] Setting a featured image for all posts imported from Twitter?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Beau Lebens

    @beaulebens

    It’s not currently part of Keyring, but if you wanted to modify things then you could hack the plugin to do it.

    http://codex.wordpress.org/Post_Thumbnails talks about them in general, and http://wordpress.stackexchange.com/questions/26138/set-post-thumbnail-with-php looks specifically at assigning a post thumbnail programmatically (the last bit is probably the most important. If you’ve just got one attachment and you want to have them all use that as the featured image, then you need to do the last bit, for each imported post)

    update_post_meta( $the_imported_post_id, '_thumbnail_id', $post_id_of_the_featured_image );

    Yeah, that’s what I’m looking for. So, where would that go in the importer code?

    I’m just setting a single image across all posts that the Twitter importer brings in.

    Plugin Author Beau Lebens

    @beaulebens

    Looks like you could do it anywhere between lines 247 and 283 in the Twitter importer.

    OK Beau, I’m sorry to keep pestering, because to be honest, I have no idea what I’m doing.

    update_post_meta( $the_imported_post_id, '_thumbnail_id', 718 );

    I’ve just put the above code in, with 718 being the attachment id of my image. Is that correct, because it won’t work.

    Nevermind, I found another solution.

    Add this bit marked “new line” before $imported++:

    }
    
            add_post_meta( $post_id, 'raw_import_data', json_encode( $twitter_raw ) );
    
            // NEW LINE (change 1001 to the image ID):
            set_post_thumbnail( $post_id, 1001 );
    
            $imported++;
        }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Setting a featured image for all posts imported from Twitter?’ is closed to new replies.
Skip to toolbar