SHARE
TWEET

Untitled

a guest Jul 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** Add meta thumbnail from the Facebook metabox field or from customizer logo field */
  2. if ( ! function_exists( 'wpseo_meta_thumb' ) ) {
  3.     function wpseo_meta_thumb() {
  4.         $thumb_url = '';
  5.         if ( is_singular() && get_post_meta( get_the_ID(), '_yoast_wpseo_opengraph-image', 1 ) ) {
  6.             $thumb_url = get_post_meta( get_the_ID(), '_yoast_wpseo_opengraph-image', 1 );
  7.         } else {
  8.             $custom_logo_id = get_theme_mod( 'custom_logo' );
  9.             $image = wp_get_attachment_image_src( $custom_logo_id , 'thumbnail' );
  10.             $thumb_url = $image[0];
  11.         }
  12.         echo '<meta name="thumbnail" content="' . $thumb_url . '" />';
  13.     }
  14.     add_action( 'wp_head', 'wpseo_meta_thumb', 1);
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top