WordPress.org

Ready to get started?Download WordPress

Forums

WordPress unexpected end of file (3 posts)

  1. henballs
    Member
    Posted 1 year ago #

    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>
  2. nsathees
    Member
    Posted 1 year ago #

    delete
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    you have it twice!!

  3. Sandra l***
    Member
    Posted 1 year ago #

    @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>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.