Created
February 26, 2019 16:27
-
-
Save jentheo/c280c40de7e4bbc270da595f26af3715 to your computer and use it in GitHub Desktop.
Add open graph tags to event archive pages
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 characters
/** | |
* 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'; | |
$tec_archive_view_og_description = 'Upcoming events description'; | |
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 ); | |
printf( '<meta property="og:description" content="%s" />%s', $tec_archive_view_og_description, 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