Analysis error: syntax error, unexpected "endif" (T_ENDIF) in a WordPress theme

This bit of code is for displaying related messages and is located in my include folder.

I recently switched from a local development environment on Mac (using MAMP) to using Windows with WAMP.

Suddenly, this error occurs in this block of code. This did not happen on my local Mac environment, and it does not happen when testing in real time.

Parse error: syntax error, unexpected "endif" (T_ENDIF)

The error indicates the second and last value endif. If I delete it, the same error will be indicated in the code, indicating the last one endif.

Any ideas? I tried to delete both specified operators endif;, and instead it produces the following error:

Parse error: syntax error, unexpected end of file

<?php  
  $orig_post = $post;  
  global $post;  
  $tags = wp_get_post_tags($post->ID);  
?>
<?php if ($tags):  ?>
<?php  
  $tag_ids = array();  
  foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;  
  $args=array(  
  'tag__in' => $tag_ids,  
  'post__not_in' => array($post->ID),  
  'posts_per_page'=>3, // Number of related posts to display.  
  'caller_get_posts'=>1 ,
  'post_type' => array( 'post', 'featured-wedding' )
  );  

  $my_query = new wp_query( $args );  
?>
<?php if($my_query->have_posts()): ?>  
    <aside class="related group">
      <h2>You May Also Like:</h2>
      <?php while( $my_query->have_posts() ) : $my_query->the_post(); ?>

        <a href="<? the_permalink()?>">
            <!-- thumbnail -->
            <?php the_post_thumbnail(array(175,175)); ?>
            <!-- post title -->
            <?php if ( 'featured-wedding' == get_post_type() ) : ?>
              <h1>Featured Wedding: <?php the_title(); ?></h1>
            <?php else: ?>
              <h1><?php the_title(); ?>: <?php if (function_exists('the_subheading')) { the_subheading('<span>', '</span>'); } ?></h1>
            <?php endif; ?>
        </a>    

      <? endwhile; ?>
    </aside> 
<?php endif; ?>
<?php  
  $post = $orig_post;  
  wp_reset_query();  
 ?>  

<?php endif; ?>
+6
source share
3 answers

short_open_tagprobably not included in php.ini. Change:

  <? endwhile; ?>

To:

  <?php endwhile; ?>

And you must change everyone else <?to <?php.

+20
source

You used here

A complete guide to developing a Worddpress theme is here: Developing a theme in Wordpress

0
source

short_open_tag php.ini OFF ON, , <?php ( php.ini.)

-2

All Articles