I use global variables to retrieve all sort of available data, especially $post and $posts, for example in order to retrieve the url of a user from the post loop instead of using get_author_posts_url( get_the_author_meta( 'ID' ) ); I do

global $post;

which I consider one less function to execute therefore better performance. am I right ? also is there a risque of using these variable?

  • If you put one image in your post that's not well optimised you're going to affect site speed 100x more than any difference this would make. This level of micro optimisation is completely pointless. It's basically a rounding error. Besides, just use get_the_author_posts_link(), which does the same thing. – Jacob Peattie May 18 at 12:50

Your Answer

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

Browse other questions tagged or ask your own question.