Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    Thanks. Subtler than just overwriting $wp_query. The *_post_link functions only use $wp_query to compute the $max_pages parameter value, so a Stack Overflow discussion recommends simply passing in that value rather than overwriting $wp_query. Which seems simpler in a way, but makes me a little nervous since it assumes future WP versions will act that way (not guaranteed: it's not part of the API/contract, but instead relies on knowledge of the code's inner variable handling). stackoverflow.com/questions/14364488/… Commented May 16, 2013 at 15:27
  • That is a good point but you are putting the variable back so overwriting $wp_query shouldn't be a problem. Honestly, I rarely even encounter this problem-- pre_get_posts makes it pretty easy to avoid. Commented May 16, 2013 at 15:33
  • Sorry, I was unclear. I agree, your method is safe. My comment about riskiness referred to the Stack Overflow solution. That other solution looks simpler on the surface (just add a parameter), but it relies on assumptions about the inner workings of WordPress core code... most likely safe, but inner code workings can change. +1 your solution because it seems more future-proof. Commented May 16, 2013 at 19:54