Skip to content
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

Function name not displayed in google search results #479

Open
benniledl opened this issue Jan 18, 2024 · 8 comments
Open

Function name not displayed in google search results #479

benniledl opened this issue Jan 18, 2024 · 8 comments

Comments

@benniledl
Copy link

Hey, when I google: _wp_filter_build_unique_id
for some reason the function name is not in the title, its just this:

Screenshot 2024-01-18 at 13-54-35 _wp_filter_build_unique_id - Google Suche

This shouldn't happen, other functions work fine:

Screenshot 2024-01-18 at 13-55-05 get_post - Google Suche

I am not sure on which pages this applies but maybe someone has a thought on why this happens?

@benniledl
Copy link
Author

I think maybe this generally affects functions with a _ prefix
this is _custom_background_cb for example
Screenshot 2024-01-18 at 14-17-38 _custom_background_cb - Google Suche

@ryelle
Copy link
Contributor

ryelle commented Jan 18, 2024

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?

@eidolonnight
Copy link

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

CleanShot 2024-01-18 at 15 30 59@2x

This does appear to be happening with other pages though, like _wp_cron.

@ryelle
Copy link
Contributor

ryelle commented Jan 18, 2024

True, when I search for _wp_cron, it appears in the second result's title.

Screenshot 2024-01-18 at 3 39 01 PM

But I'm not sure what we're doing differently, because we have the full title in <title> (and og:title, if that's worth anything here).

Screenshot 2024-01-18 at 3 39 35 PM

@eidolonnight
Copy link

Were changes recently made to these pages? Perhaps it just needs to be re-indexed. Everything is looking fine currently.

@benniledl
Copy link
Author

benniledl commented Jan 18, 2024

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??

Screenshot 2024-01-18 222939

For example this site: https://wp-kama.com/function/_wp_cron
Has the exact same string in every title element.

@ryelle
Copy link
Contributor

ryelle commented Jan 18, 2024

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:

Screenshot 2024-01-18 at 4 47 27 PM

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.

@benniledl
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants