Closed nicholasio closed 8 months ago
@nicholasio I have also noticed an issue with get_head endpoint when appending the url param with
'${getWPUrl()}/?s=${params.search}
If the WP url returned by getWPUrl() has a trailing slash, this will add double slash to //?s=
where get_head endpoint returns page not found.
I needed to do const wpUrl = getWPUrl().replace(/\/$/, '');
first to remove the trailing slash
Thanks @lucymtc Here are a few things I found:
get_head
function.get_head
query and thus makes the framework default to the metadata of the first post returned.I'm not sure if we can rely on on Yoast to generate the meta tags for the search page.
Alternative solution: Have the SearchStrategy manually build the yoast_seo object and yoast_html fields manually with basica meta tags.
@nicholasio for the issue:
I found what the problem is and opened an Issue and PR in Yoast
I tried to override the validate callback for the URL, the way to do this would be to register a get_head endpoint from our side as if $override
is set to false in register_rest_route
WP merges with newer overriding if duplicate keys exist.
The problem is that you need to pass in the exact arguments that the original register_rest_route
(the one in Yoast) is called with, and the callback function depends on an instance of\Yoast\WP\SEO\Routes\Indexables_Head_Route
which has dependencies in other Yoast classes and doesn't make it straight forward to instantiate the class. Unless Yoast exposes an instance of the class but I haven't found anything so far.
I tested other hooks to try override the validation callback without success.
Update on fix for _"Searching for multiple words crashes the gethead query and thus makes the framework default to the metadata of the first post returned." has been merged into Yoast via this PR https://github.com/Yoast/wordpress-seo/pull/21032
Opened PR https://github.com/10up/headstartwp/pull/663 for: Yoast is not properly detecting a search page via the get_head function. Yoast does not yoast_head to the WordPress search endpoint.
Update on fix for _"Searching for multiple words crashes the gethead query and thus makes the framework default to the metadata of the first post returned." has been merged into Yoast via this PR Yoast/wordpress-seo#21032
Looks like the PR merged will be released in Yoast 22.0.
Describe the bug
There seem to be a few issues with the Yoast get_head endpoint that is not properly recognizing the requested page as a search page.
Steps to Reproduce
Screenshots, screen recording, code snippet
No response
Environment information
No response
WordPress information
No response
Code of Conduct