Last active
March 1, 2018 21:26
-
-
Save cliffordp/5ed25b8bfb024efe73d1ce6c42d960aa to your computer and use it in GitHub Desktop.
The Events Calendar: Add Open Graph to <head> of Events Archive views.
This file contains 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 characters
<?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