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

Search from paged page should reset to first page #18

Open
helgatheviking opened this issue Jan 24, 2019 · 0 comments
Open

Search from paged page should reset to first page #18

helgatheviking opened this issue Jan 24, 2019 · 0 comments

Comments

@helgatheviking
Copy link
Owner

helgatheviking commented Jan 24, 2019

Ex: if you are on /directory/page/2 and you run a search, you should be sent back to /directory. The easiest way to do this is to make the form action equal to the permalink. This is what is used to be, but it was removed (I think to support custom $_GET params and maybe use as a widget). How to achieve this without changing the action?

Would want to redirect to page 1 when form is submitted, but not in cases where search results may legit span multiple pages.

Form $_POST ? pre_get_posts?

Sadly, this did not work:

function search_filter( $query ) {
  if ( isset( $_POST['as'] ) ) {
        $query->set( 'paged', 0 );
  }
}
add_action( 'pre_get_posts', 'search_filter' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant