I have a site (a few actually) that stores jobs with multiple categories and locations etc. I also have a form that allows simple searching of jobs. The make this work by searching multiple things e.g. Accountants in London I have used
pre_get_postson the job post type archive page to filter the results based on search. The code used to do this is linked below:
This works great and the job archive page now shows all jobs that matched the search criteria used. However there is a problem with pagination.
If the search results multiple pages, although the results should pagination (and they show the correct number of pages), as soon as you click on one of those pages, the pre_get_posts alterations are lost and it defaults to showing page 2 for example of all the jobs.
It seems like I need to pre_get_posts to work on all the paginated pages too. If anyone could assist with this I would be very grateful.
Thanks in advance.
- The topic ‘Using pre_get_posts Breaks Pagination’ is closed to new replies.