Skip to content

Pagination causes search results to 404 #75

@dismantl

Description

@dismantl

This is essentially a clone of closed issue #69 since the problem still persists with the latest release. I'm using Wordpress 5.8.1, Geo-my-wp 3.7.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\" />";

I will submit a pull request with this patch shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions