Closed marcissimus closed 3 years ago
Hi, thanks for contributing :)
My question: how come that the post_link
filter does not work for you? The function the_permalink
calls get_the_permalink
which uses either the post_link
filter or the page_link
filter (through get_page_link
) or the post_type_link
filter (through get_post_permalink
)...
What I found testing on a site using EDD and the Vendd theme was that the search template uses a custom loop which the does not pass the in_the_loop()
if statement... It's actually an Vendd theme bug (or feature?)
Sometimes things take a while... Just in case someone else runs into the same problem:
The search result contains links to posts which do not include the search query ?hilite=...
. Therefore clicking the link will not highlight the search term in the detailed post.
Another plugin or theme implemented the_permalink
filter hook and replaced the URL without taking the URL query into consideration.
In my case, it was a theme from https://cpothemes.com/, which provides custom post types that let you configure a so called "Custom URL". If the custom URL is set to any value, the search query will be lost when such custom post shows up in the search results. I consider this a bug but the setting might as well be called a feature.
I added an if-statement into search.php
to skip over posts that have a "Custom URL" setting (since they are just redirecting to another page).
Hi Marcus, thanks for updating and adding more details. On the next update with 6.2 compatibility, I'll do some testing with the the_permalink hook...
great. here's another test case: i had permalinks returned in local format like /my-category/page
so it's not necessarily a complete URL.
Some templates for search results use the_permalink() and then previous url filters won't work in case of custom post types with rewrite rules (for example Easy Digital Downloads, post type "downloads").
PS: I love the simplicity of this plugin!