-
-
Save fervous/f84de602ba84caa70e92efee09dcb6ff to your computer and use it in GitHub Desktop.
WC Vendors Pro - Use Vendor Store Icon as Yoast SEO OpenGraph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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