Open nguyentuandat opened 3 years ago
@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.
@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 book/?genre=action
will make the code think it should return indexable data of the page of the action
genre (url/book-genre/action
). However, it does then not seem to use the title of that indexable...
Thank you! Are you have any temporary solution for this issue @Djennez ?
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 title-ptarchive-<taxonomy_name>
which does not exist.
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 is_term_archive()
first, which matches and so it returns term archive data. However:
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 is_post_type_archive()
first, which matches, so it returns data for a posttype archive. In both cases, when switching the order of the cases, it will hit the one which matches first.
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 don't feel like matching the order is the solution here.
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.
The code should likely account for WPQueries that return 2 types of results, and determine which one to use.
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.
I tried adding taxonomy template for taxonomy that only use with certain custom type, but YoastSEO evaluate is_post_type_archive()
in taxonomy template.
So, title tag is empty at display taxonomy archive and input title tag for each term at term edit page.
According to WordPress template hierarchy and rewrite rule, http://examlpe.com/some-post-type/some-term/
call archive-some_post_type.php
.
But often I want to let WordPress display taxonomy archive at http://examlpe.com/some-post-type/some-term/
.
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
orwebsite.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 returnMovies - 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/
get_header(); ?>