Advertisement
richieboo

FB Sharing for WP by Chad Von Lind, get_the_excerpt() trunc

Oct 6th, 2011
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <!-- Begin FB Sharing for WP by Chad Von Lind. Get the latest code here: http://vonlind.com/?p=539  -->
  2.     <?php
  3.         $thumb = get_post_meta($post->ID,'_thumbnail_id',false);
  4.         $thumb = wp_get_attachment_image_src($thumb[0], false);
  5.         $thumb = $thumb[0];
  6.         $default_img = 'http://www.maskc.org/img/logo/MASKC.jpg';
  7.     ?>
  8.    
  9.     <?php if(is_single() || is_page()) { ?>
  10.         <meta property="og:type" content="article" />
  11.         <meta property="og:title" content="<?php single_post_title(''); ?>" />
  12.         <meta property="og:description" content="<?php
  13.         while(have_posts()):the_post();
  14.              $excerpt_truncated = get_the_excerpt();
  15.              if ( strlen(get_the_excerpt()) > 274)
  16.              {
  17.                $excerpt_truncated = substr(get_the_excerpt(), 0, 274)."...";
  18.              }
  19.         $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $excerpt_truncated);
  20.         echo apply_filters('the_excerpt_rss', $out_excerpt);
  21.         endwhile;   ?>" />
  22.         <meta property="og:url" content="<?php the_permalink(); ?>"/>
  23.         <meta property="og:image" content="<?php if ( $thumb[0] == null ) { echo $default_img; } else { echo $thumb; } ?>" />
  24.     <?php  } else { ?>
  25.         <meta property="og:type" content="article" />
  26.         <meta property="og:title" content="<?php bloginfo('name'); ?>" />
  27.         <meta property="og:url" content="<?php bloginfo('url'); ?>"/>
  28.         <meta property="og:description" content="<?php bloginfo('description'); ?>" />
  29.         <meta property="og:image" content="<?php  if ( $thumb[0] == null ) { echo $default_img; } else { echo $thumb; } ?>" />
  30.     <?php  }  ?>
  31. <!-- End FB Sharing for WP -->
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement