Skip to content

Instantly share code, notes, and snippets.

@danmaby
Created April 4, 2018 09:37
Show Gist options
  • Save danmaby/a8624dcdde9f192f28a83c0361b17870 to your computer and use it in GitHub Desktop.
Save danmaby/a8624dcdde9f192f28a83c0361b17870 to your computer and use it in GitHub Desktop.
Replace og:image on custom post type archive
<?php
// CPT Talks - replace og:image
add_action( 'wp_head', 'prefix_add_og_image', 10, 1 );
function prefix_add_og_image( $img ) {
if( is_post_type_archive( 'post-type-archive-wpldn_talk' ) ) {
echo '<meta property="og:image" content="https://www.wpldn.uk/wp-content/uploads/2018/03/2018-02-22-WPLDN_Primary-Image-2.jpg" />';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment