How to Style WordPress Functions With Span

enter image description here

I already checked this solution, but I still don’t know why I’m getting a syntax error for this code:

<?php 
 $args = array('post_type' => 'posts', 'posts_per_page' => 3, 'order'
 => 'ASC', 'orderby' => 'title');

 //$posts = new WP_Query($args);
  if (have_posts()){
  while ( have_posts() ) : the_post();
  get_template_part( 'content', get_post_format());

  //if ($posts->have_posts()) : while($post->have_posts()) : $posts->the_post();

  echo "<span class="post-date">get_the_date()</span>";
  echo "<a href=".get_permalink()."><h2 class='post-title'>".get_the_title()."</h2></a>";
  echo the_post_thumbnail();
  echo get_the_excerpt(); 
  echo "<a href=".get_permalink()."><span class='read-more'>
  Read More >></span></a>";


  endwhile;
}
?>

The one I’m having trouble with is the first echo: get_the_date(). All I’m trying to do is wrap the function in a span so that I can change the color of the date.

The error message I’m getting is: parse error, expecting ', ", or ';'

(Sorry the error message goes away when I try to take a screenshot). Please let me know if you know how to fix this, thanks.

Read more here: How to Style WordPress Functions With Span

Leave a Reply

Your email address will not be published. Required fields are marked *