解析错误:语法错误,在localhost上测试的文件意外结束(wordpress主题)

时间:2014-06-18 06:34:36

标签: php wordpress parsing localhost

我正在尝试从头开始创建一个wordpress主题,然后在localhost上测试它。此代码来自front-page.php

我一直收到这个错误:

Parse error: syntax error, unexpected end of file in C:\wamp\www\director\front-page.php on line 56 (第56行是代码的最后一行)

使用此代码:

<?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(); ?>

我检查了但我似乎没有遗漏任何结束标签或东西。我有什么遗失或没有看到的东西吗?

1 个答案:

答案 0 :(得分:0)

关闭你的最后一个foreach循环...

<?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(); ?>