Add pagination to table generated by wp_query

As already pointed out in comments

  • gb_bypass_filter is not a valid parameter for WP_Query. If you want to suppress to effect of filters on your query, add 'suppress_filters' => true to your query arguments

  • previous_posts_link() does not accept two arguments, only one. Unlike next_posts_link(), it does not have the second $max_pages parameter. So you can remove that part from your function

  • When using WP_Query, you should use wp_reset_postdata(), not wp_reset_query(). The latter is used with query_posts which you should never ever use.

  • If this is a static frontpage, you should use page as value to your paged parameter, not paged

I had a second look at your code, and it does seem that your code is a bit disjointed. Make the following adjustments

  • Move your pagination to just below the line endwhile or </table> , depending where you would want to display your pagination. The latter however looks like the correct place

  • Move wp_reset_postdata() to just below your pagination, this should all be between endwhile and the first occurance of } else {. The reason for this is, when there is no posts, what are you resetting 🙂

Apart from that, your code should work and paginate as normal. If it does not, try the following

  • Add the suppress_filters argument to your query. This will be a test to see if you don’t have external filters that are modifying your query

  • Turn debug on, and check for any obvious bugs and errors

  • Flush your permalinks again by visiting the permalink settings page

  • Dump your custom query (var_dump($deals);) and check thst all inputs and outputs is what you expect them to be. Pay attention to max_num_pages and make sure that you have more than one page

  • Deactivate all plugins one by one to eliminate them as possible causes of your issue. Also, clear all caches. Also try your code on a bundled theme

Apart from that, it is really difficult to say what is causing your issue