Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This is a page template for custom nivo slider, it gives unexpected endwhile on line 1 error. I can't find out whats wrong.

<?php
               /*
Template Name: sliderpage
*/?>
<?php get_header(); ?>

<div class="span-24" id="contentwrap">

    <?php //get_sidebars('left'); ?>

    <div class="span-14">
    <div id="slider" class="nivoSlider">
<?php
  $myslider=new WP_query('showposts=5&cat=13');
  //var_dump($myslider);
  if($myslider->have_posts()):
  while ($myslider->have_posts()) : $myslider->the_post(); ?>
 <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">






 <img src="<?php echo $featured_image_url [0]; ?>" alt="" title="<?php the_title(); ?>" />
 </a>
 <?php endwhile; endif; ?>

  <?php wp_reset_query();
?>
</div>

        <div id="content">  

        </div>

    </div>


<?php get_sidebars('right'); ?>



</div>

<?php get_footer(); ?>
share|improve this question
add comment

closed as too localized by Michael, kaiser, toscho May 7 '12 at 14:15

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 0 down vote accepted

I wasn't able to recreate the error. Maybe it's coming from <?php get_sidebars('right'); ?>

I did change your code a little, but it didn't give the "unexpected endwhile" error you spoke of. If it's coming from line 1 I'd guess it's the header.php file?

Here is the adjusted code if you want to try it:

<?php 
/* 
Template Name: sliderpage */
?>
<?php get_header(); ?>
<div class="span-24" id="contentwrap">
  <div class="span-24" id="contentwrap">
    <div class="span-14">
      <?php
        $myslider=new WP_query('showposts=5&cat=13');
        //var_dump($myslider);
        if($myslider->have_posts()):
        while ($myslider->have_posts()) : $myslider->the_post(); 
        ?>
        <div id="slider" class="nivoSlider">
          <a href="<?php the_permalink() ?>" class="post-image">
            <img src="<?php echo $featured_image_url [0]; ?>" alt="slider-image" title="<?php the_title(); ?>" />
          </a>        
          <?php endwhile; endif; wp_reset_query(); ?>          
        </div>

      <div id="content"></div>
    </div>
  <?php get_sidebars('right'); ?>
  </div>
<?php get_footer(); ?>

Your code also used <? instead of <?php. Short Tags aren't supported in WordPress. Although this isn't the cause of the error it's good to practice proper coding standards.

share|improve this answer
    
Yes it used <? tag which was creating problem, now it works –  Amna Ahmed May 7 '12 at 11:34
    
I had 2 editors open comparing your code with a slider I use. I must have posted the wrong one (egg on face). –  Jeremy Jared May 7 '12 at 16:12
    
I just checked my code I don't see the short-tag in there, maybe I need some sleep? –  Jeremy Jared May 7 '12 at 16:15
    
You are right, i edited code after posting. –  Amna Ahmed May 7 '12 at 17:40
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.