Showing related posts (custom post type) outside of the loop October 13, 2022 by Tarik Billa Try using $wp_query global variable: global $wp_query; $postid = $wp_query->post->ID;