The $post
variable inside your function does not point to anything. You are declaring global $wp_query
(which you are not actually using), but not global $post
.
The $post
variable inside your function does not point to anything. You are declaring global $wp_query
(which you are not actually using), but not global $post
.