I am having a problem with a local $page variable, especially when using it in The Loop. Is it a reserved variable of Wordpress? Also where can I find a list of all those global variables?


Yes. It is an "inside the Loop" global.

$page (int) The page of the post, as specified by the query var page.


It is setup and used by setup_postdata which executes at every iteration of a standard Loop. Though meant for use inside the Loop, the variable would still be set after the Loop to the last data it was given (unless specifically unset and I don't think it is, but am not swearing to that).

| improve this answer | |
  • But how can a variable become global only in a loop? – user25893 Oct 3 '13 at 22:26
  • the_post() initializes them? – user25893 Oct 3 '13 at 22:28
  • 2
    @Maxwell : see the edit – s_ha_dum Oct 3 '13 at 22:35

The wordpress codex is definitely your friend finding such information... :) and, yes, $post is one of wordpress's Global Variables.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy