Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Created July 14, 2016 23:32
Show Gist options
  • Save bentasm1/91fc6995a63f84aa190b345307369694 to your computer and use it in GitHub Desktop.
Save bentasm1/91fc6995a63f84aa190b345307369694 to your computer and use it in GitHub Desktop.
WC Vendors Pro - Use Vendor Store Icon as Yoast SEO OpenGraph
// Set Vendors Store Icon as Open Graph image on shop page
function my_opengraph_image( $img ) {
if ( WCV_Vendors::is_vendor_page() ) {
$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
$vendor_id = WCV_Vendors::get_vendor_id( $vendor_shop );
$store_icon_src = wp_get_attachment_image_src( get_user_meta( $vendor_id, '_wcv_store_icon_id', true ), 'full' );
// see if the array is valid
if ( is_array( $store_icon_src ) ) {
$img = $store_icon_src[0];
}
return $img;
}
}
add_filter( 'wpseo_opengraph_image', 'my_opengraph_image', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment