Currently, changed my localhost site to a new domain with a new url. Checked the PHP logs and got the following error?
[06-Feb-2014 19:47:51] PHP Parse error: syntax error, unexpected '[' in /var/www/... on line 128
Here is my code:
<div class="home_story_container">
<a href="<?php echo get_permalink( $post->ID ); ?>"><div class="home_preview_photo" style="background-image:url('<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post- thumbnail' ); ?>
<?php echo $image[0]; ?>
<?php endif; ?>')">
</div></a>
<?php $category = get_the_category($post->ID)[0]->name; ?>
<?php
$category_link = get_category_link( get_cat_ID( $category ) );
?>
<a href="<?php echo esc_url( $category_link ); ?>"><span class="home_cat_tag"><?php echo $category; ?></span></a>
<br />
<a href="<?php echo get_permalink( $post->ID ); ?>"><span class="home_title"><?php echo get_the_title($post); ?></span></a>
<br /><br />
<span class="home_paragraph"><?php
$page_data = get_page( $post->ID );
echo strip_tags($page_data->post_excerpt);
?> – <a href="<?php echo get_permalink( $post->ID ); ?>">Read More »</a></span>
</div>
Specifically, I'm getting an error on this line:
<?php $category = get_the_category($post->ID)[0]->name; ?>
What's the problem?