Global variables

No we got a soft reject and one of the issues are the global variables.

global variable should be used restrictively and only if theme really needs to.

Here’s an example how this would be acceptable:

My question do we need to use a function for global variables that comes with wp like $post and other

$post is created automatically by WordPress, if you’re in a template file you don’t need to call this as global, only if you’re within function scope as your screenshot shows.

Thanks for your reply, but the snapshot is what is been suggested by the reviewer to add global variables inside a function. But in some cases we arecalling $post and some other wp variables. My question do we need to create function for these variables also?!

No suppose that we use woocommerce in some places like header where we should use like

Global woocommerce;

So do we have to create function for that as well??