Keyring Social Importers
[resolved] Setting a featured image for all posts imported from Twitter? (6 posts)

  1. rjt1985
    Posted 2 years ago #

    Is this possible?

    If so, how would I go about doing it?

    Many thanks,



  2. Beau Lebens
    Plugin Author

    Posted 2 years ago #

    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 );

  3. rjt1985
    Posted 2 years ago #

    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.

  4. Beau Lebens
    Plugin Author

    Posted 2 years ago #

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

  5. rjt1985
    Posted 2 years ago #

    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.

  6. rjt1985
    Posted 2 years ago #

    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 );

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Keyring Social Importers
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic