2

I am getting this error : Parse error: syntax error, unexpected T_OBJECT_OPERATOR in wp-content/themes/phil/page.php on line 104

This is my code:

<?php
    $todaysDate = date ('M d');
    $event_query = new WP_Query('showposts=5&category_name=events&meta_key=Date&meta_compare=>=&meta_value='.$todaysDate.'&orderby=meta_value=order=ASC');
?>
<?php
    if (event_query->have_post()) : while ($event_query->have_post()) : $event_query->the_post();
    $eventMeta = get_post_meta($post->ID, 'Date', true);
    $eventDate = strtotime($eventMeta);
    $displayDate = date ('M d', $eventDate);
?>
<li>
<span class="date"><?php echo $displayDate ; ?></span>
<span><a href="<?php the_permalink();?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></span></li>
<?php endwhile; else:?>
<li>No Upcoming events</li>
<?php endif;?>

I am pretty new to this PHP stuff and WOrdpress so let me know what am I doing wrong. or paste the code to replace.

2 Answers 2

2

I'm going to go out on a limb and guess that this line :

  if (event_query->have_post()) : while ($event_query->have_post()) : $event_query->the_post();

Should be this:

  if ($event_query->have_post()) : while ($event_query->have_post()) : $event_query->the_post();

You were missing the $ in your variable name.

Sign up to request clarification or add additional context in comments.

Comments

1

You are missing a $ infront of event_query in

if (event_query->have_post())

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.