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
<meta name="robots"> incorrectly set to 'noindex,follow' for Posts post type archive #13016
Comments
Hmmm, I don't know what happens here 'exactly', but I found this: On SEO -> Search Appearance -> Content Types -> This in itself shouldn't break things, I suppose. But for some reason, the So, at either "Yes" or "No" for the option Show the archive for Posts in search results?, the value "off" or "on" is saved to the database instead of a boolean. As a string, by default, is a true boolean, the noindex meta is set per this condition: wordpress-seo/frontend/class-frontend.php Lines 746 to 748 in 04b6bae
I don't know if posts having an archive is wrong, and that's why this option in our plugin is acting strange, or if this slider is expected to work and isn't. |
Right, this was my diagnosis too.
Posts having an archive should be fine, although it's not a default behavior for WordPress. I think something is wonky with the slider / settings page behavior. |
Took some time to investigate this further. I think it's this line that is causing problems:
Only if it's not a _builtin posttype, defaults will be created. Since Posts are a builtin posttype, these archive defaults are never created. Since we only validate and save options after comparing them to our default values, this option never gets saved "properly"; with a boolean instead of a string. wordpress-seo/inc/options/class-wpseo-option-titles.php Lines 327 to 333 in f25b106
After removing the check for the _builtin bool, the option was successfully saved to the database. This raises more questions for me:
Will have to check this with the devs :) |
The builtin post type returns home_url (even if it's static page) as archive page if "posts" page isn't set. Maybe it's possible to remove _the builtin check (only for There is still breadcrumbs as an issue... This archive page will be excluded from the sitemap (because "posts" page doesn't exists), but it's possible to use filter wpseo_sitemap_post_type_archive_link to add custom URL into post sitemap. |
Please give us a description of what happened.
We've created a blog post archive at
/blog/
following this approach of defininghas_archive=>true
for thepost
post type.However, after we hit save for "Search Appearance Settings" (when modifying unrelated settings), the robots meta tag is incorrectly set to "noindex,follow":
Please describe what you expected to happen and why.
We'd expect the
<meta name="robots">
meta tag to be absent from the page because we've checked "Yes" for the "Show the archive for Posts in search results" option:How can we reproduce this behavior?
functions.php
file./blog/
and inspect source. Observe that<meta name="robots">
is absent from the page./blog/
and inspect source. Observe that<meta name="robots" content="noindex,follow"/>
is unexpectedly present.Technical info
I've debugged the problem down to this line:
wordpress-seo/frontend/class-frontend.php
Line 746 in 04b6bae
This particular option returns "off" as its value, which causes "noindex" to be set for
$robots['index']
I'm not familiar enough with the settings codebase to guess why "Show the archive for Posts in search results?" might be saved as "off" but happy to debug further if someone can point me in the right direction.
Used versions
The text was updated successfully, but these errors were encountered: