php - How to add a meta og:image tag in woocommerce product details page and set image as product image? -


i new wordpress.

to show product image while sharing on whatsapp, want og:image meta tag on details page of specific product.

so tried in head section of theme file:

if ( is_product() ) {      global $product; echo '<meta property="og:image" content="'.$product->get_image($size = 'shop_thumbnail').'">'; } 

but error :

call member function get_image() on non-object

how echo image url in meta tag?

try below code image

<?php  if ( is_product() ) {     global $post, $product;     echo '<meta property="og:image" content="'.get_the_post_thumbnail_url( $post->id, 'shop_thumbnail' ).'">';  }  ?> 

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -