Function name not displayed in google search results
Opened this issue · 8 comments
The title
tag should include the function in both cases, so it's not a problem with the site. I wonder if Google thinks it's not a real part of the title.
We could switch up the code reference entry titles to prefix with the reference type, like "Function: _the_function_name() | Developer.WordPress.org" ? That way it wouldn't start with the underscore.
@eidolonnight @thetinyl What do you think?
I don't think it's the underscore that's a problem. Here is an example from the Drupal project docs: _forum_icon | forum.module | Drupal 4.6 | Drupal API
This does appear to be happening with other pages though, like _wp_cron.
Were changes recently made to these pages? Perhaps it just needs to be re-indexed. Everything is looking fine currently.
Maybe Google becomes confused due to the presence of multiple different titles, thinking it's inconsistent and it needs to figure out the title itself. It seems to extract the page name "Function" (stripping the seemingly wrong string starting with _) from the <title>
tag and then derives the site name from other elements such as <link rel="alternate">
, combining them, trying to take it's best guess. Maybe if we take the exact same title in every element, google will "trust" the title and not try to make its own guess??
For example this site: https://wp-kama.com/function/_wp_cron
Has the exact same string in every title element.
Were changes recently made to these pages?
There was #399, but it didn't change the title on these pages.
One thing I noticed while looking is that Google is changing the title slightly. It has the sections separated by -
, rather than the |
. For example, the page has <title>get_theme() – Function | Developer.WordPress.org</title>
, but google shows:
Oh, the suffix is different too- I just caught it because of @benni1516's screenshot (thanks!). It uses that site_name
value for the last segment, "WordPress Developer Resources" rather than "Developer.WordPress.org".
So google is definitely adjusting the title. Maybe it sees the h1
on the page is "_wp_cron(): int|false" and decided that isn't a human-friendly string? I'm not sure why the Drupal & wp-kama sites work, though, if that's the case.
I think it strips _wp_cron() - because it is not a human-friendly string (as you said) and then it rather takes the sitename WordPress Developer Resources rather than the domain name because that is also a more human-friendly string.