Last active
September 22, 2016 19:43
Revisions
-
paperrobots revised this gist
Sep 22, 2016 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,9 +14,13 @@ function fb_opengraph() { $img_src = get_stylesheet_directory_uri() . '/img/opengraph_image.jpg'; } if($post->post_excerpt != '') { $excerpt = strip_tags($post->post_excerpt); $excerpt = str_replace("", "'", $excerpt); } elseif ($post->post_content != ''){ $excerpt = strip_tags($post->post_content); $excerpt = str_replace("", "'", $excerpt); $excerpt = wp_trim_words($excerpt, 25); } else { $excerpt = get_bloginfo('description'); } -
paperrobots revised this gist
Sep 22, 2016 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,7 @@ function fb_opengraph() { } else { $img_src = get_stylesheet_directory_uri() . '/img/opengraph_image.jpg'; } if($excerpt = $post->post_excerpt) { $excerpt = strip_tags($post->post_excerpt); $excerpt = str_replace("", "'", $excerpt); @@ -21,10 +22,10 @@ function fb_opengraph() { } ?> <meta property="og:title" content="<?php echo get_the_title(); ?>"/> <meta property="og:description" content="<?php echo $excerpt; ?>"/> <meta property="og:type" content="article"/> <meta property="og:url" content="<?php echo get_permalink(); ?>"/> <meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/> <meta property="og:image" content="<?php echo $img_src; ?>"/> -
paperrobots created this gist
Sep 22, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ function doctype_opengraph($output) { return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"'; } add_filter('language_attributes', 'doctype_opengraph'); function fb_opengraph() { global $post; if(has_post_thumbnail($post->ID)) { $img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'medium'); } else { $img_src = get_stylesheet_directory_uri() . '/img/opengraph_image.jpg'; } if($excerpt = $post->post_excerpt) { $excerpt = strip_tags($post->post_excerpt); $excerpt = str_replace("", "'", $excerpt); } else { $excerpt = get_bloginfo('description'); } ?> <meta property="og:title" content="<?php echo the_title(); ?>"/> <meta property="og:description" content="<?php echo $excerpt; ?>"/> <meta property="og:type" content="article"/> <meta property="og:url" content="<?php echo the_permalink(); ?>"/> <meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/> <meta property="og:image" content="<?php echo $img_src; ?>"/> <?php } add_action('wp_head', 'fb_opengraph', 5);