I agree, it seems bad practice to take away certain filters without giving more of a notice. There should be a few versions where BOTH work, otherwise, our custom code breaks after updating plugin. If we change our code before updating plugin, then it still breaks because the old plugin doesn’t support the new filters.
Things seem to be getting a little sloppy here. Better documentation and better changelogs to say what exactly was changed and to what (especially for filters/hooks).
@nikitasp,
Thanks for reaching out!
We are still working on our documentation and hope to have all that outlined very soon. For now, here are the new hooks that you need to switch to:
aioseo_title
aioseo_thumbnail_size
Our old version had many different hooks that began with different (inconsistent) prefixes like aiosp_
or aioseop_
so we took the opportunity to standardize them all to aioseo_
.
Because the code base is so different there are different hooks as well, so if you find something is not working as expected, just reach out and we will let you know how to use it as well.
@benjaminprojas thank you for a such quick response, I’ll check it!
@nikitasp, is this happening for all pages/posts? The title that is passed into that filter is the same title we use anywhere we are displaying a title.
Since you are a dev, if you feel comfortable looking at the code you can see where it is defined here:
all-in-one-seo-pack/app/Common/Meta/Title.php
on line 184.
Oops, looks like its working now? 😀
@benjaminprojas now #archive_title contains “Archive: ” string.
And now the title looks like “Archive: Reviews | Website name” instead of “Reviews | Website name” earlier.
How we can avoid this?
Thanks.
Yeah, the new hook name is working like a charm 🙂
But now the function is using some dynamics titles, as I see:
if ( is_archive() ) {
$postType = get_queried_object();
$options = aioseo()->options->noConflict();
if ( $options->searchAppearance->dynamic->archives->has( $postType->name ) ) {
return $this->prepareTitle( aioseo()->options->searchAppearance->dynamic->archives->{ $postType->name }->title );
}
}
Instead of labels, like earlier.
After a small research, seems now we should use one more WordPress core filter get_the_archive_title
with code like that:
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>' ;
} elseif ( is_tax() ) { //for custom post types
$title = sprintf( __( '%1$s' ), single_term_title( '', false ) );
} elseif (is_post_type_archive()) {
$title = post_type_archive_title( '', false );
}
return $title;
});
Am I right?
This is a great question. Our code should strip out the Archive:
part of it, but if you are seeing it appear, we will need to take a closer look at that.
What are your title settings and which type of archive is this? I’m assuming it’s for a custom post type?
What are your title settings and which type of archive is this?
It’s simple and seems default for all websites #archive_title - #site_title
🙂
I’m assuming it’s for a custom post type?
Yeah, of course.
@benjaminprojas if it’s not conceived and it is a mistake, than I think you’d better use post_type_archive_title()
instead of get_the_archive_title()
in app/Common/Utils/Tags.php
on line 910:
case 'archive_title':
$title = wp_strip_all_tags( get_the_archive_title() ); // <--- here
return $sampleData ? __( 'Sample Archive Title', 'all-in-one-seo-pack' ) : $title;
Many thanks.
@nikitasp,
You are correct! We’ve made the adjustment and it will be fixed in the next release 🙂
Thanks for working with us on this!
@benjaminprojas,
Nice! You’d better hurry up with this update it’s very important for SEO titles for a ton of plugin’s users.
Thanks.
@nikitasp,
Our 4.0.9 release includes this fix. Can you update and let us know if its working for you?