• I have this custom php in my index.php. I’m trying to do a custom theme and I’m getting an “Parse error: syntax error, unexpected end of file”

    I can’t spot my error! Any help appreciated!

    <?php get_header(); ?>
    
    <div class="container">
        <div class="main-content">
          <?php
          query_posts('posts_per_page=6&offset=1');
          if ( have_posts() ) : while ( have_posts() ) : the_post();
          ?>
            <div <?php post_class() ?>>
              <h2>
                <a href="<?php the_permalink() ?>">
                  <?php the_title(); ?>
                </a>
              </h2>
              <?php the_content(''); ?>
            </div>    
    
          <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
            <div <?php post_class() ?>>
              <h2>
                <a href="<?php the_permalink() ?>">
                  <?php the_title(); ?>
                </a>
              </h2>
              <?php the_content(''); ?>
            </div>
          <?php endwhile; ?>
          <?php endif; ?>
        </div>
        <div class="sidebar">
      </div>
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • delete
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    you have it twice!!

    @nsathees is right. This is how your file should look like:

    <?php get_header(); ?>
    
    <div class="container">
        <div class="main-content">
          <?php
          query_posts('posts_per_page=6&offset=1');
          ?>
          <?php if (have_posts()) : ?>
          <?php while (have_posts()) : the_post(); ?>
            <div <?php post_class() ?>>
              <h2>
                <a href="<?php the_permalink() ?>">
                  <?php the_title(); ?>
                </a>
              </h2>
              <?php the_content(''); ?>
            </div>
          <?php endwhile; ?>
          <?php endif; ?>
        </div>
        <div class="sidebar">
      </div>
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WordPress unexpected end of file’ is closed to new replies.