Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active March 1, 2018 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/5ed25b8bfb024efe73d1ce6c42d960aa to your computer and use it in GitHub Desktop.
Save cliffordp/5ed25b8bfb024efe73d1ce6c42d960aa to your computer and use it in GitHub Desktop.
The Events Calendar: Add Open Graph to <head> of Events Archive views.
<?php
/**
* The Events Calendar: Add Open Graph to <head> of Events Archive views.
*
* @link https://gist.github.com/cliffordp/5ed25b8bfb024efe73d1ce6c42d960aa
* @link http://ogp.me/
*/
/**
* The Events Calendar: Add Open Graph to <head> of Events Archive views.
*
* @link https://gist.github.com/cliffordp/5ed25b8bfb024efe73d1ce6c42d960aa
* @link http://ogp.me/
*/
function cliff_add_open_graph_tec_archive_views() {
// !!! CHANGE THIS URL !!!
$tec_archive_view_og_image_url = 'https://theeventscalendar.com/content/uploads/2013/07/screenshots4-2_single-event.png';
if ( ! class_exists( 'Tribe__Events__Main' ) ) {
return false;
}
$tecmain = Tribe__Events__Main::instance();
if (
is_main_query()
&& is_post_type_archive( $tecmain::POSTTYPE )
) {
printf( '<meta property="og:image" content="%s" />%s', $tec_archive_view_og_image_url, PHP_EOL );
}
}
add_action( 'wp_head', 'cliff_add_open_graph_tec_archive_views' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment