Der obs_meta_title
Filter filtert die Ausgabe des SEO Titels auf Produkt -und Kategorieseiten. Wenn das Yoast SEO Plugin verwendet wird, auch den SEO Titel für Yoast SEO.
Dieser Filter läuft, wenn der Header einer Produkt -oder Kategorieseite erstellt wird.
Der Filter ist ab OBS Pages Version 1.7.3 verfügbar. Ab Version 1.9 ist der dritte Parameter $explore_path dazu gekommen.
Beispiel-Anwendung über functions.php in Child-Theme
/**
* Adjust the SEO title of certain product or category page for a given path
*
* @param string $title The already set title.
* @param string $path The path of the current OBS page.
* @param array $explore_path The explore_path array holding lots of info about the current page.
*
* @return string The new to set title.
*/
function obs_adjust_seo_title( string $title, string $path, array $explore_path ): string {
// TODO: get the SEO title for the given path.
$seo_title = obs_get_seo_title( $path );
if ( null !== $seo_title ) {
$title = $seo_title;
}
return $title;
}
add_filter( 'obs_meta_title', 'obs_adjust_seo_title', 10, 3 );
Anleitung zur Integration von Hooks
Eine Integration im Code
/**
* Filter the title of the category page / product page before outputting / forwarding to Yoast
*
* @param string $title The title from Elastic.
* @param string $current_path The path of the called category / product page.
* @param array $explore_path The explore_path array holding lots of info about the current page.
*/
$title = apply_filters( 'obs_meta_title', $title, Oneboxshop_Pages_Functions::get_url_path(), $this->explore_path );