Hello! I’m writing a widget which is based on the page it is displayed on. So if it is_single I use global $post and then can do all the stuff I need. But if another widget querying database like ‘recent posts’ is executed before my code, global $post contains the last queried post and not the one displayed on, that’s why my widget displays incorrect results. I tried to use global $wpdb and global $wp_query to resolve which post page is widget actually displaying on, but these seem to have the data related to the wrong one too. What should I do to always be able to get the post the widget is displayed on?
- The topic ‘Problem with global $post in widget’ is closed to new replies.