I'd be grateful if anyone can cast an eye over this error with my php? It worked locally but when I published it live it generated this error:
******* UPDATE: If there is null data then the error is created so I need to create an ELSE statement right?
Warning: Invalid argument supplied for foreach() in [line #]
Thanks for all input and help!
<?php
$categories = get_the_category();
foreach($categories as $cat):?>
<a href="<?php echo get_category_link($cat->term_id);?>" class="badge badge-primary" style="margin-bottom:5px;"><?php echo $cat->name;?></a>
<br>
<?php endforeach;?>
<?php
$tags = get_the_tags();
foreach($tags as $tag):?>
<a href="<?php echo get_tag_link($tag->term_id);?>" class="badge badge-light"><?php echo $tag->name;?></a>
<?php endforeach;?>