Home Forums WC Vendors Pro Support Titile, Description, Keywords on domain.com/vendors/vendorname Reply To: Titile, Description, Keywords on domain.com/vendors/vendorname

#59798
Anonymous
Inactive

OK, one more point please))) =D

This code should work for Yoast… if you use ‘pv_shop_description’ and ‘pv_shop_name’ on vendors pages


// SEO Overwrite meta description for vendor pages
function overwrite_vendor_meta($desc) {

    // Return the default value if we're not on a vendor shop page
    if(!WCV_Vendors::is_vendor_page()) return $desc;

    // Get the vendor description and return it
    $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
    $vendor_id   = WCV_Vendors::get_vendor_id( $vendor_shop );
    $desc = get_user_meta( $vendor_id, 'pv_shop_description', true );

    // Remove line breaks
    $desc = str_replace(array("\r", "\n"), " ", strip_tags($desc));
    // Remove extra spaces
    $desc = preg_replace( '/\s+/', ' ', $desc );
    // Escape special characters
    $desc = htmlspecialchars($desc);
    // Shorten it to 156 characters (153 + '...')
    $desc = substr($desc ,0,153).'...';

    return $desc;
}
add_filter( '_yoast_wpseo_metadesc', 'overwrite_vendor_meta', 10, 1);

// SEO Overwrite meta description for vendor pages
function overwrite_vendor_title($title) {

    // Return the default value if we're not on a vendor shop page
    if(!WCV_Vendors::is_vendor_page()) return $title;

    // Get the vendor description and return it
    $vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
    $vendor_id   = WCV_Vendors::get_vendor_id( $vendor_shop );
    $title = get_user_meta( $vendor_id, 'pv_shop_name', true );

    return $title;
}
add_filter( '_yoast_wpseo_title', 'overwrite_vendor_title', 10, 1);

Enjoy!

This website uses cookies to ensure you get the best experience on our website.