Skip to content

Instantly share code, notes, and snippets.

@nathanrice
Last active December 12, 2015 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nathanrice/4683845 to your computer and use it in GitHub Desktop.
Save nathanrice/4683845 to your computer and use it in GitHub Desktop.
Use Genesis Doctitle and Meta Description with Jetpack's Open Graph tags on entry pages.
<?php
add_filter( 'jetpack_open_graph_tags', 'nr_jetpack_open_graph_tags_filter' );
/**
* Filter open graph tags to use Genesis doctitle and meta description instead.
*
* @author Nathan Rice
* @link https://gist.github.com/4683845
*/
function nr_jetpack_open_graph_tags_filter( $tags ) {
/** Do nothing if not on an entry page */
if ( ! is_singular() )
return $tags;
/** Pull from custom fields */
$title = genesis_get_custom_field( '_genesis_title' );
$description = genesis_get_custom_field( '_genesis_description' );
/** Maybe set new values */
$tags['og:title'] = $title ? $title : $tags['og:title'];
$tags['og:description'] = $description ? $description : $tags['og:description'];
return $tags;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment