Error: Attempt to read property "ID" on null
I have the following error Attempt to read property ID on null
in this code snippet
global $wp_query;
$categories = get_the_terms($wp_query-post-ID, 'live_stream_categories');
$cat_slug = '';
$live_stream_true = False;
if(!empty($categories)){
foreach ($categories as $cat) {
if($cat-slug != 'live-stream')
{
$cat_slug = $cat-slug;
}
if($cat-slug == 'live-stream')
{
$live_stream_true = True;
}
}
}
However I'm not sure what the workaround would be. Any advice? I've took over this site from a previous developer