-
AuthorPosts
-
December 6, 2021 at 10:16 am #1331674
Hi there,
I need to let me SEO tool (AIO SEO) handle all titles. Unfortunately your suggested way doesn´t work. I also contacted their support in order to make sure I get the right return function but also not luck.
Any ideas? I tried:
add_filter(‘avf_title_tag’, ‘avia_change_title_tag’, 10, 2);
function avia_change_title_tag( $title, $wptitle )
{
return wp_get_document_title();
}As well as:
add_filter(‘avf_title_tag’, ‘avia_change_title_tag’, 10, 2);
function avia_change_title_tag( $title, $wptitle )
{
return $wptitle;
}- This topic was modified 2 years, 11 months ago by El.
December 6, 2021 at 10:17 am #1331677Also tried:
remove_filter(‘avf_title_tag’, ‘avia_wpseo_change_title_adjustment’, 10, 2);
December 10, 2021 at 10:30 am #1332264Hi,
Thank you for the inquiry.
We have checked the plugin documentation but we cannot find any reference about how it generates the page or post title and how to retrieve it. And we are not sure if the plugin is also using a filter to override the default title.
Please ask the plugin authors how the plugin generate the title and if there is a way to retrieve that value. There should be a function that we could use in combination with the avf_title_tag filter.
Best regards,
IsmaelDecember 10, 2021 at 11:57 am #1332289Here is their response and suggestion. Enfold doesn´t really take it into account though:
…
Thanks for reaching out.
We filter the core WP Title tag function to manage the Page Title of your page, so you’ll just need to return that in your filter.
add_filter(‘avf_title_tag’, ‘avia_change_title_tag’, 10, 2);
function avia_change_title_tag( $title, $wptitle )
{
return wp_get_document_title();
}December 14, 2021 at 4:03 am #1332681Hi,
Thank you for the info.
What happens when you override the avia_set_title_tag function by declaring it again?
function avia_set_title_tag() { return wp_get_document_title(); }
If this is not working, then the function wp_get_document_title is not the function that the plugin is using to retrieve the title.
Best regards,
IsmaelDecember 14, 2021 at 2:40 pm #1332774Strange. All of these actions produce no change – are you sure these are actually working with the latest enfold?
remove_filter(‘avf_title_tag’, ‘avia_wpseo_change_title_adjustment’, 10, 2); // no worky
add_filter(‘avf_title_tag’,’avia_new_title’);
function avia_new_title() {
$title = “X: “.get_the_title();
return $title;
}add_filter(‘avf_title_tag’, ‘avia_change_title_tag’, 10, 2);
function avia_change_title_tag($title, $wptitle)
{
return “X: “.$wptitle;
}function avia_set_title_tag()
{
return “X: “.wp_get_document_title();
}function avia_set_title_tag()
{
return wp_get_document_title();
}December 15, 2021 at 8:24 am #1332889Hi,
Do you remove the cache and disable the compression after adjusting the code? Declaring the avia_set_title_tag should override the default function and return the value specified, so if you do this for example..
function avia_set_title_tag() { return "ECHO"; }
.. all page title should be set to “ECHO”. You can also disable the default title tag by adding this code.
remove_action( 'wp_head', 'av_theme_slug_render_title' );
Or this..
add_action("init", function() { remove_action( 'wp_head', 'av_theme_slug_render_title' ); }, 10);
You can then display your own title tag.
function av_theme_slug_render_title_mod() { echo '<title>' . wp_get_document_title() . '</title>'; } add_action( 'wp_head', 'av_theme_slug_render_title_mod' );
Or..
function av_theme_slug_render_title_mod() { echo '<title>' . get_the_title(get_the_ID()) . '</title>'; } add_action( 'wp_head', 'av_theme_slug_render_title_mod' );
Unfortunately, we cannot find any reference about how to retrieve the page or post title value set in the AIOSEO settings.
Best regards,
IsmaelDecember 15, 2021 at 1:21 pm #1332947Ismael,
There must be some other issue I cannot trace. All these changes have no effect on the Title.
remove_action('wp_head', 'av_theme_slug_render_title'); remove_filter('avf_title_tag', 'avia_wpseo_change_title_adjustment'); add_action('init', function() { remove_action('wp_head', 'av_theme_slug_render_title'); remove_filter('avf_title_tag', 'avia_wpseo_change_title_adjustment'); }, 10); function av_theme_slug_render_title_mod() { echo '<title>X ' . wp_get_document_title() . '</title>'; } add_action( 'wp_head', 'av_theme_slug_render_title_mod' );
I assume you have validated this in a clean enfold install? It does not seem to work for me. I can also not trace any another plugin setting these titles. I also haven´t overwritten those templates in our child theme.
Best,
ElDecember 16, 2021 at 9:51 am #1333065Hi,
Thank you for following up.
It actually works fine on our end even without the modifications above.
back: https://imgur.com/TD9eE4W
front: https://imgur.com/5CXwJuzThere is probably another plugin in your installation that overrides the default title.
Best regards,
IsmaelDecember 16, 2021 at 10:53 am #1333085Ismael,
thank you. I will investigate. It might be due to us being forced to use an older version until AIOSEO adds API support back into their current version. Thanks for testing!
Best
ElmarDecember 20, 2021 at 6:41 am #1333486 -
AuthorPosts
- The topic ‘Overwriting Meta Title fails’ is closed to new replies.