• Resolved hanzzsolo

    (@hanzzsolo)


    Help I am getting a Parse error on this code. what am I doing wrong?
    ERROR is BOLD

    <body>

    <div id=”header”>

    <h1>“><?php bloginfo(‘name’);?></h1>
    <?php bloginfo(‘description’);?>

    </div>

    <div id=”container”>

    <?php if(have_posts()):?><?php while(have_posts()):the_post();?>
    <?php the_title(); ?> after the_post(); ?> and before <?php endwhile; ?>
    <?php endwhile;?> ERROR ON THIS LINE
    <?php endif;?>

    </div>

    </body>

Viewing 2 replies - 1 through 2 (of 2 total)
  • look at it in a more ..easier to read way.

    if (have_posts(): 
    
      while (have_posts()):
    
        the_title(); "after the_posts(); ?> and before "
    
      endwhile;
    endwhile;
    endif;

    What you have here is actually 2 errors.

    1) You do not have a <?php before the_post(); ?> so it’s going to echo out after the_post(); to your screen. I’m guessing your just trying to output the second the_post(); as a string.

    2) You have 2 endwhiles; with only 1 loop.

    <div id="container">
    <?php
         if (have_posts()) :
            while (have_posts()) : the_post(); ?>
               <?php the_title(); ?> after the_post(); <br />
            <?php endwhile;
         endif;
    ?>
    </div>

    Anytime you start <?php your telling the parser to execute whatever’s inside as php so when you placed that there it’s actually thinking to use that first endwhile, as the endwhile so the second endwhile shows up and is’nt needed.

    If you want to use < and >’s as text on your screen use &lt ; and &gt ; respectively.

    Thread Starter hanzzsolo

    (@hanzzsolo)

    Thanks for the help. Now I am getting when I view the page (this is a fresh install of WP also)

    Hello world! after the_post(); ?>

    the tutorial I am using says it should be looping. the link is included: http://www.wpdesigner.com/2007/02/25/wp-theme-lesson-5-the-loop/

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘getting parse error – 1st time theme’ is closed to new replies.