I am on the single.php file and I am trying to get the category of a blog post which is either Blog or News.
The reason I want to do this is that the website I am building has both a Blog and a News page and I am using the 'Posts' to generate the pages for both. What I want to do is display the 'Blog' or 'News' text in the breadcrumbs.
This is actually working on localhost by doing the following:-
<?php
$catergory = get_the_category()->name; # $catergory = get_the_category()[0]->name;
echo $catergory;
?>
But when I view it on the single page when I upload it to the server I get the following error:-
Parse error: syntax error, unexpected '[', expecting ',' or ';' in /var/www/vhosts/m360.co.uk/irongate.m360.co.uk/wp-content/themes/irongate/single.php on line 23
Which is basically the first line from the example above.
Any ideas why this is happening?