How to check in the wpseo_title filter from Yoast SEO whether the title for the page has been manually set via the Yoast SEO settings form:
those. in code
add_filter( 'wpseo_title', function( $title ) {
//если $title не задан вручную, то изменяем $title
return $title;
}, 10);
Share
Hi, this is how you can define the title variable set for a post in yoast
I have done this in function.php
and already in the template itself in header.php
The use of an array of global variables by the authors of Yoast is, of course, another matter =). But, thanks for the solution))
Michael Molina , I'm talking about the very fact of storing data in a global array (a stone in the Yoast SEO garden)
Well, it's more like I did it, you may not even need it
And if the title is not set, then what goes into the
$title
variable? Post title? Then just compare it to the title. Empty line? Well, check for a blank line.I checked – Yoast SEO's auto-generation gets there – i.e. the variable $ title turns out to be what Yoast itself generated by its templates for post types …
Shane , Then you can substitute the value obtained from the database when loading the meta field at the lowest level.