Skip to content

Instantly share code, notes, and snippets.

@fervous
Forked from bentasm1/functions.php
Created September 3, 2016 03:41
Show Gist options
  • Save fervous/f84de602ba84caa70e92efee09dcb6ff to your computer and use it in GitHub Desktop.
Save fervous/f84de602ba84caa70e92efee09dcb6ff 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