Fitoussi / geo-my-wp

Advanced mapping and geolocation plugin for Wordpress
https://geomywp.com
36 stars 22 forks source link

Pagination causes search results to 404 #69

Closed dismantl closed 3 years ago

dismantl commented 3 years ago

I'm using Wordpress 5.5.1, Geo-my-wp 3.6.1, Posts Locator extension.

When I submit the search form on my site, I get a 404 error because of the page URL parameter. An example of the URL params from a search:

?address%5B%5D=Baltimore%2C+MD%2C+USA&page=1&per_page=10&lat=39.290385&lng=-76.612189&form=1&action=fs

This would lead to a 404. However if I change page= to paged=, it works again, and correctly paginates. I'm not sure if this is the issue, but I noticed that page is a reserved query variable in Wordpress: https://codex.wordpress.org/WordPress_Query_Vars

I tried this fix but it did not work. The only workaround I was able to find was patching includes/template-functions/class-gmw-search-form-helper.php:

408,413c408
<       $output .= "<input type=\"hidden\" id=\"gmw-page-{$id}\" class=\"gmw-page\" name=\"page\" value=\"1\" />";
<
<       // Fix for home page pagination when going to the first page.
<       if ( is_front_page() || is_single() ) {
<           $output .= "<input type=\"hidden\" id=\"gmw-paged-{$id}\" class=\"gmw-paged\" name=\"paged\" value=\"1\" />";
<       }
---
>       $output .= "<input type=\"hidden\" id=\"gmw-paged-{$id}\" class=\"gmw-paged\" name=\"paged\" value=\"1\" />";
Fitoussi commented 3 years ago

Hello @dismantl,

I apologize for not replying here sooner. I just noticed your post.

However, I have already provided a fix to this issue in one of the most recent releases of GEO my WP.

Please let me know if you have updated GEO my WP and if it took care of the issue for you.

dismantl commented 3 years ago

I am still running into this issue with the latest version of the plugin (3.7). Any suggestions?

dismantl commented 3 years ago

Also the workaround I posted above last October is still the only thing I am able to do to get it to work again.

dismantl commented 3 years ago

I could submit a PR with the workaround if that would be helpful.