Support » Fixing WordPress » problem with image associated with url when sharing

  • Resolved giant slayer


    I am having trouble assigning/defining a specific image I want associated with a url when it is shared.

    I have a weekly post that is automatically generated each week. I also have this post automatically shared to my personal facebook wall and fan page for my art.

    The image facebook pulls is not the one I want. I have embeded the following tags in the head section of the post.

    <link rel="image_src" type="image/jpeg" href="" />
    <meta property="og:image" content="" />

    This is the image I want.
    This is what gets picked up if I visit the post and then manually share, but it is not getting this image when the post is automatically posted to word press and then to facebook.

    Anyone have any ideas how I can define the image associated with the url at the time of the post?

    Thank you,

Viewing 1 replies (of 1 total)
  • giant slayer


    I found a work around by attaching an image and assigning it to be the featured image/post thumbnail. Here is the code.

    $new_post_id=wp_insert_post( $my_post );
    $filename='/wp-content/themes/slayer/ipadthumb/' . sprintf("%s", $freebackgrounds->background[$i]->imagefilename);
    $wp_filetype = wp_check_filetype(basename($filename), null );
    $attachment = array(
       'post_mime_type' => $wp_filetype['type'],
       'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
       'post_content' => '',
       'post_status' => 'inherit'
    $attach_id = wp_insert_attachment( $attachment, $filename, 37 );
    wp_publish_post( $new_post_id );

Viewing 1 replies (of 1 total)
  • The topic ‘problem with image associated with url when sharing’ is closed to new replies.