• Dariusz Lorek

    (@dariuszlorek)


    I want to add that code to <head> section:

    <link rel=”image_src” href=”<?php the_post_thumbnail(); ?>” / >

    and nothing happend… I want to display from post site the thumbnail of that in <head> section.

    What about that?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Jonas Grumby

    (@ss_minnow)

    The functions.php file in your active theme also needs to have add_theme_support( 'post-thumbnails' );

    See this page

    Thread Starter Dariusz Lorek

    (@dariuszlorek)

    already done… still nothing

    That code in site source look that way:
    <link rel=”image_src” href=”” / >

    esmi

    (@esmi)

    I don’t think it will work in the <head> section as the_post_thumbnail() outputs image markup – not the image src. Why exactly do you want to add a post thumb to the head of your pages?

    Jonas Grumby

    (@ss_minnow)

    I assumed that meant header.

    Thread Starter Dariusz Lorek

    (@dariuszlorek)

    That code; <link rel=”image_src” href=”URL HERE” / > will give Facebook a standard 1 image for url…

    It work for main <head>, but I want for every post another image.

    esmi

    (@esmi)

    Do you mean a favicon?

    Thread Starter Dariusz Lorek

    (@dariuszlorek)

    no…

    When you add post in Facebook wall, Facebook search images or find that code “image_src” and add it to one option for image url. I can do it for all site by add that code to normal <head> in header.php but All in One Seo allowes me to add another code to each post page <head>. And in that head I need to attach the code URL from thumbnail to do that icon.

    I would also like to do this.

    With the new Facebook Open Graph stuff, you can define a thumbnail for that page in your <head> of the form
    <meta property="og:image" content="[image url]"/>.

    I would like to use
    <meta property="og:image" content="<?php the_post_thumbnail(); ?>"/>
    but since this is outside the loop, the tag returns nothing.

    Is there a way to get this to work outside the loop?

    Thanks

    anyone managed to make this work?

    hope this helps, found it on google

    <html xmlns="https://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml" xmlns:og="https://opengraphprotocol.org/schema/" <?php language_attributes(); ?>>
    <?php if (have_posts()):while(have_posts()):the_post();endwhile;endif;?>
    <!-- Facebook Opengraph -->
    	<meta property="fb:app_id" content="your_app_id" />
    	<meta property="fb:admins" content="your_admin_id" />
    	<meta property="og:url" content="<?php the_permalink() ?>"/>
    <?php if (is_single()) { ?>
    	<meta property="og:title" content="<?php single_post_title(''); ?>" />
    	<meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>" />
    	<meta property="og:type" content="article" />
    	<meta property="og:image" content="<?php echo wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ) ?>" />
    <?php } else { ?>
    	<meta property="og:site_name" content="<?php bloginfo('name'); ?>" />
    	<meta property="og:description" content="<?php bloginfo('description'); ?>" />
    	<meta property="og:type" content="website" />
    	<meta property="og:image" content="<?php bloginfo('template_url') ?>/path/to-your/logo.jpg" />
    <?php } ?>

    more info here:
    https://www.werewp.com/wordpress/how-to-integrate-facebook-open-graph-protocol-into-your-wordpress-theme/

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Post thumbnail in head…’ is closed to new replies.