Skip to main content
fixed formatting
Source Link
cjbj
  • 15k
  • 16
  • 42
  • 89

On a category archive page, in a filter called from a block outside a loop, I noticed that the get_postget_post function with a null first parameter returns the first loop's post.

Is it supposed to return such a value ? I would have imagined that the global $post variable should have a value only in a loop or on a post page.

On a category archive page, in a filter called from a block outside a loop, I noticed that the get_post function with a null first parameter returns the first loop's post.

Is it supposed to return such a value ? I would have imagined that the global $post variable should have a value only in a loop or on a post page.

On a category archive page, in a filter called from a block outside a loop, I noticed that the get_post function with a null first parameter returns the first loop's post.

Is it supposed to return such a value ? I would have imagined that the global $post variable should have a value only in a loop or on a post page.

Source Link
challet
  • 111
  • 4

Global $post value outside the loop

On a category archive page, in a filter called from a block outside a loop, I noticed that the get_post function with a null first parameter returns the first loop's post.

Is it supposed to return such a value ? I would have imagined that the global $post variable should have a value only in a loop or on a post page.