WordPress global $post variable is empty
问题 I'm working on a wordpress plugin(managing background image), when I try to use global $post; print_r($post); the object is empty. Probably there is some required data (I dont know what.) Please help me if you know. 回答1: The WordPress global variable $post contains the data of the current Post within the The Loop. This means that WordPress will assign a value to this variable in each loop iteration. Consecuently, if you're trying to access $post from anywhere in your code outside the WP loop,