WordPress.org

Ready to get started?Download WordPress

Forums

Post thumbnail in head... (11 posts)

  1. dariuszlorek
    Member
    Posted 4 years ago #

    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?

  2. Jonas Grumby
    Member
    Posted 4 years ago #

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

    See this page

  3. dariuszlorek
    Member
    Posted 4 years ago #

    already done... still nothing

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

  4. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    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?

  5. Jonas Grumby
    Member
    Posted 4 years ago #

    I assumed that meant header.

  6. dariuszlorek
    Member
    Posted 4 years ago #

    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.

  7. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    Do you mean a favicon?

  8. dariuszlorek
    Member
    Posted 4 years ago #

    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.

  9. nonimage
    Member
    Posted 3 years ago #

    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

  10. crismdq
    Member
    Posted 3 years ago #

    anyone managed to make this work?

  11. cemrepacun
    Member
    Posted 3 years ago #

    hope this helps, found it on google

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://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:
    http://www.werewp.com/wordpress/how-to-integrate-facebook-open-graph-protocol-into-your-wordpress-theme/

Topic Closed

This topic has been closed to new replies.

About this Topic