-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yoast Title in custom post archive-posttype.php is blank when add more query string #16436
Comments
@nguyentuandat can you share the necessary code / reproduction steps to reproduce your issue from an empty WordPress installation? The current information is not sufficient enough to work with. |
Thank @Djennez I just update reproduction steps and code. |
Hmmm, I can reproduce the issue, with our Test helper plugin as well. It looks like adding this argument is making our plugin use the indexable data of the taxonomy that is requested in the argument. So |
Thank you! |
A bit of extra investigation; This goes wrong on $title = $this->options->get_title_default( 'title-ptarchive-' . $post_type ); because the indexables think we're on both a posttype archive as well as a taxonomy archive. So it tries to get the default title of The reason the indexables get confused here is because when building the indexable for the current page, we rely on WPQuery, and it looks like WPQuery is doing a query for both the posttype as well as the taxonomy. We have 2 functions where this goes wrong: public function for_current_page() {
$indexable = false;
switch ( true ) {
case $this->current_page->is_simple_page():
$indexable = $this->find_by_id_and_type( $this->current_page->get_simple_page_id(), 'post' );
break;
case $this->current_page->is_home_static_page():
$indexable = $this->find_by_id_and_type( $this->current_page->get_front_page_id(), 'post' );
break;
case $this->current_page->is_home_posts_page():
$indexable = $this->find_for_home_page();
break;
case $this->current_page->is_term_archive():
$indexable = $this->find_by_id_and_type( $this->current_page->get_term_id(), 'term' );
break;
case $this->current_page->is_date_archive():
$indexable = $this->find_for_date_archive();
break;
case $this->current_page->is_search_result():
$indexable = $this->find_for_system_page( 'search-result' );
break;
case $this->current_page->is_post_type_archive():
$indexable = $this->find_for_post_type_archive( $this->current_page->get_queried_post_type() );
break;
case $this->current_page->is_author_archive():
$indexable = $this->find_by_id_and_type( $this->current_page->get_author_id(), 'user' );
break;
case $this->current_page->is_404():
$indexable = $this->find_for_system_page( '404' );
break;
} hits public function get_page_type() {
switch ( true ) {
case $this->is_search_result():
return 'Search_Result_Page';
case $this->is_static_posts_page():
return 'Static_Posts_Page';
case $this->is_home_static_page():
return 'Static_Home_Page';
case $this->is_home_posts_page():
return 'Home_Page';
case $this->is_simple_page():
return 'Post_Type';
case $this->is_post_type_archive():
return 'Post_Type_Archive';
case $this->is_term_archive():
return 'Term_Archive';
case $this->is_author_archive():
return 'Author_Archive';
case $this->is_date_archive():
return 'Date_Archive';
case $this->is_404():
return 'Error_Page';
} hits Code that combines these results, like the line at the top of my post, will try to combine these results. I don't feel like matching the order is the solution here. The code should likely account for WPQueries that return 2 types of results, and determine which one to use. |
I agree it wouldn't be the cleanest solution, but would fix the immediate problem in this case by picking one of the options. Also the behaviour would be somewhat defined and explainable, as opposed to 'random'. Or make it filterable which one to prefer.
I expect it would be hard to create a good UX for this. Either it would have to be determined by Yoast which to pick (which would be the same as above). Or the user would be able to pick for each combination of post-types and terms which SEO title to use. This second solution would get complicated really fast. |
Along the lines of Niels' first suggestion: it would help if Yoast picks one of the two options (say "post type archive") as a default and makes the behavior (checking order) customizable via a filter. |
Hi, I have same proble when I am improving a WordPress site now. According to WordPress template hierarchy and rewrite rule, |
For now, change query string (instead of taxonomy name) is a simple solution for me. :D |
Please give us a description of what happened.
I have
movies
)When i query in archive-movies.php with url like:
website.com/movies
or
website.com/movies?a=b
(witha
is not a query_var)The title replacement work fine like:
Movies Archive - Site title
But when i add more query such as:
website.com/movies?country=us
(country is my custom taxonomy )The title just return
Movies - Site title
(not match SEO title replacement)I tried to update SEO title replacement but it was not effected ( follow this post ).
I tried add filter:
But just show empty string.
Please describe what you expected to happen and why.
My target the title should be
Movies Archive US - Site title
.How can we reproduce this behavior?
Post name
|https://my-web.com/sample-post/
book
, add genreaction
%%pt_plural%% Archive %%page%% %%sep%% %%sitename%%
https://my-web.com/book/
--> Site title show correct.Books Archive - Site Name
https://my-web.com/book/?genre=action
--> Site title show incorrect.Books - Site Name
instead ofBooks Archive - Site Name
Technical info
Yoast SEO with up to date wordpress 5.5.3
Used versions
The text was updated successfully, but these errors were encountered: