Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i'm trying to create a wordpress theme from scratch and then test it on localhost. this code is from front-page.php

i keep getting this error:

Parse error: syntax error, unexpected end of file in C:\wamp\www\director\front-page.php on line 56 ( line 56 is the last line of the code)

with this code:

<?php get_header(); ?>

<?php
    $posts= get_posts(array('numberposts' => 4,'category' => 3, orderby => 'title'));
    foreach ($posts as $post) : setup_postdata($post); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>
?>

<?php
    $args= array('post_type' => 'businesses', 'posts_per_page' => 1, 'tax_query' => array(array('taxonomy' => 'business-type', 'field' => 'slug', 'terms' => 'featured')));

    $featuredBusiness=get_posts($args);
        foreach ($featuredBusiness as $post) : setup_postdata($post);
?>

    <div id="featured" class="group">
    <div class="business-info right-col">
        <hr/>
        <h3>Featured Business:</h3>
        <h2><?php the_title(); ?></h2>
        <p><?php the_excerpt(); ?></p>
    </div>
    <div class="impact-image">
        <?php print get_the_post_thumbnail($post->ID, 'storefront'); ?>
    </div>
    </div>

    <?php endforeach; ?>

    <div id="main" class="group">
        <div id="posts" class="left-col">

            <?php
                $posts= get_posts('posts_per_page=3');
                foreach ($posts as $post) : setup_postdata($post); ?>

            <div class="post group">
                <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                    <div class="byline">by <?php the_author_posts_link(); ?>
                        on <a href="<?php the_permalink(); ?>"><?php the_time('l F d, Y'); ?></a>
                    </div>
                <p><?php the_excerpt(); ?></p>
            </div>

            <?php
                $blogID=get_page_by_path('blog');
                $blogLink=get_page_link($blogID->ID);
            ?>
            <a class="visit" href=" <?php print $blogLink; ?>">Visit the Blog</a>

        </div>
    <?php get_sidebar(); ?>
    </div>
    <?php get_footer(); ?>

i checked but i don't seem to be missing any closing tags or something. is there something i'm missing or not seeing?

share|improve this question
    
Can you post the get_footer() function? –  Paul Dessert Jun 18 at 6:37
    
You've missed to end your last foreach loop –  Pieter Goosen Jun 18 at 6:41
    
@PieterGoosen Ahh thank you it works now! –  user3751159 Jun 18 at 6:48
add comment

1 Answer

up vote 0 down vote accepted

Just close your last foreach loop ...

<?php get_header(); ?>

<?php
    $posts= get_posts(array('numberposts' => 4,'category' => 3, orderby => 'title'));
    foreach ($posts as $post) : setup_postdata($post); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>
?>

<?php
    $args= array('post_type' => 'businesses', 'posts_per_page' => 1, 'tax_query' => array(array('taxonomy' => 'business-type', 'field' => 'slug', 'terms' => 'featured')));

    $featuredBusiness=get_posts($args);
        foreach ($featuredBusiness as $post) : setup_postdata($post);
?>

    <div id="featured" class="group">
    <div class="business-info right-col">
        <hr/>
        <h3>Featured Business:</h3>
        <h2><?php the_title(); ?></h2>
        <p><?php the_excerpt(); ?></p>
    </div>
    <div class="impact-image">
        <?php print get_the_post_thumbnail($post->ID, 'storefront'); ?>
    </div>
    </div>

    <?php endforeach; ?>

    <div id="main" class="group">
        <div id="posts" class="left-col">

            <?php
                $posts= get_posts('posts_per_page=3');
                foreach ($posts as $post) : setup_postdata($post); ?>

            <div class="post group">
                <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                    <div class="byline">by <?php the_author_posts_link(); ?>
                        on <a href="<?php the_permalink(); ?>"><?php the_time('l F d, Y'); ?></a>
                    </div>
                <p><?php the_excerpt(); ?></p>
            </div>

            <?php
                $blogID=get_page_by_path('blog');
                $blogLink=get_page_link($blogID->ID);
            ?>
            <a class="visit" href=" <?php print $blogLink; ?>">Visit the Blog</a>
 <?php endforeach; ?>
        </div>
    <?php get_sidebar(); ?>
    </div>
 <?php get_footer(); ?>
share|improve this answer
    
Agarwal Thank you so much!! It works now –  user3751159 Jun 18 at 6:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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