/**
* This removes the Yoast WordPress SEO plugin generated title on all Datafeedr store pages.
*/
add_action( 'init', 'dfr_remove_wpseo_title' );
function dfr_remove_wpseo_title( $title ) {
global $wpseo_front;
if (is_page ( 4656 )) {
remove_filter('wp_title', array($wpseo_front, 'title'), 15, 3 );
}
}
/**
* This removes the Yoast WordPress SEO plugin generated canonical links on all Datafeedr store pages.
*/
add_filter( 'wpseo_canonical', 'dfr_remove_wpseo_canonical' );
function dfr_remove_wpseo_canonical( $canonical ) {
if (is_page ( 4656 )) {
$canonical = false;
}
return $canonical;
}
/**
* This removes the Yoast WordPress SEO plugin generated meta description on all Datafeedr store pages.
*/
add_filter( 'wpseo_metadesc', 'dfr_remove_wpseo_metadesc' );
function dfr_remove_wpseo_metadesc( $description ) {
if (is_page ( 4656 )) {
$head = $GLOBALS['DFR_PLUGIN']->shop_content->head;
preg_match('~<meta name="description" content="(.*?)"~', $head, $output);
$description = $output[1];
}
return $description;
}
/**
* This removes the Yoast WordPress SEO plugin generated meta keywords on all Datafeedr store pages.
*/
add_filter( 'wpseo_metakey', 'dfr_remove_wpseo_metakey' );
function dfr_remove_wpseo_metakey( $keywords ) {
if (is_page ( 4656 )) {
$head = $GLOBALS['DFR_PLUGIN']->shop_content->head;
preg_match('~<meta name="keywords" content="(.*?)"~', $head, $output);
$description = $output[1];
}
return $keywords;
}
/**
* This gets the right title for product pages
*/
add_filter( 'wpseo_title', 'dfr_update_title' );
function dfr_update_title( $title ) {
if (is_page ( 4656 )) {
return $GLOBALS['DFR_PLUGIN']->shop_content->title . ' ' . get_bloginfo( 'name' );
}
return $title;
}
/**
* Gets the right OG title
*/
add_filter( 'wpseo_opengraph_title', 'dfr_opengraph_title' );
function dfr_opengraph_title( $title ) {
if (is_page ( 4656 )) {
$title = $GLOBALS['DFR_PLUGIN']->shop_content->title;
}
return $title;
}
/**
* Gets the right facebook image for product pages.
*/
add_filter( 'wpseo_opengraph_image', 'dfr_remove_og_image' );
function dfr_remove_og_image( $image ) {
if( !is_page ( 4656 ) ) {
return $image;
} else {
if ( is_page ( 4656 ) ) {
$head = $GLOBALS['DFR_PLUGIN']->shop_content->head;
preg_match('~<meta property="og:image" content="(.*?)"~', $head, $output);
$image = $output[1];
return $image;
}
}
} Reference:
https://forums.datafeedr.com/showthread.php?p=46750