Der obs_open_graph_title
Filter filtert die Ausgabe des Open Graph Titles, og:title auf Produkt -und Kategorieseiten. Wenn das Yoast SEO Plugin verwendet wird, der og:title 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.8 verfügbar.
Beispiel-Anwendung über functions.php in Child-Theme
/**
* Filter the open graph title og:title before output
* Return empty string, if no og:title should be output
*
* @param string $title The meta title to be filtered and output as og:title.
* @param array $explore_path The explore_path array holding lots of info about the current page.
*/
function obs_adjust_og_title( string $title, array $explore_path ): string {
// TODO: get the og:title for the given path.
$og_title = obs_get_og_title( $explore_path );
if ( null !== $og_title ) {
$title= $og_title ;
}
return $title;
}
add_filter( 'obs_open_graph_title', 'obs_adjust_og_title', 10, 2 );
Anleitung zur Integration von Hooks
Eine Integration im Code
/**
* Filter the open graph title og:title before output
* Return empty string, if no og:title should be output
*
* @param string $title The meta title to be filtered and output as og:title.
* @param array $explore_path The explore_path array holding lots of info about the current page.
*/
$open_graph_title = apply_filters( 'obs_open_graph_title', $title, $this->explore_path );