Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
1.2 kB
3
Indexable
Never

// Modify document title
add_filter('pre_get_document_title', 'marketking_seo_title', 1000);
function marketking_seo_title($title){
    if (marketking()->is_vendor_store_page()){
        $vendor_id = marketking()->get_vendor_id_in_store_url();
        if ($vendor_id !== 0){
            $title = marketking()->get_store_name_display($vendor_id);
        }
    }
    return $title;
}

// Modify og:title
add_filter('wp_head', 'marketking_modify_og_title', 1);
function marketking_modify_og_title() {
    if (marketking()->is_vendor_store_page()) {
        $vendor_id = marketking()->get_vendor_id_in_store_url();
        if ($vendor_id !== 0) {
            $og_title = marketking()->get_store_name_display($vendor_id);
            echo '<meta property="og:title" content="' . esc_attr($og_title) . '" />' . "\n";
        }
    }
}

add_filter('wpseo_canonical', 'marketking_remove_canonical_vendor_pages', 10, 1);
add_filter('get_canonical_url', 'marketking_remove_canonical_vendor_pages', 10, 1);

function marketking_remove_canonical_vendor_pages($canonical) {
    if (marketking()->is_vendor_store_page()) {
        return false;
    }
    return $canonical;
}
Leave a Comment