Parse error:syntax error

时间:2013-09-16 作者:pmulders

我是Wordpress的新手。我正在尝试创建Wordpress主题。但我得到了一个错误:

Parse error: syntax error, unexpected \'meta\' (T_STRING) in \\xampp\\htdocs\\wordpress\\wp-content\\themes\\theme\\index.php on line 31
错误文件Index.php

    <?php get_header(); ?>
<div id="container">

    <div id="content">
    <?php /* The Loop — with comments! */ ?>
<?php while ( have_posts() ) : the_post() ?>

<?php /* Create a div with a unique ID thanks to the_ID() and semantic classes with post_class() */ ?>
                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php /* an h2 title */ ?>
                    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( __(\'Permalink to %s\', \'your-theme\'), the_title_attribute(\'echo=0\') ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

<?php /* Microformatted, translatable post meta */ ?>
                    <div class="entry-meta">
                        <span class="meta-prep meta-prep-author"><?php _e(\'By \', \'your-theme\'); ?></span>
                        <span class="author vcard"><a class="url fn n" href="<?php echo get_author_link( false, $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( __( \'View all posts by %s\', \'your-theme\' ), $authordata->display_name ); ?>"><?php the_author(); ?></a></span>
                        <span class="meta-sep"> | </span>
                        <span class="meta-prep meta-prep-entry-date"><?php _e(\'Published \', \'your-theme\'); ?></span>
                        <span class="entry-date"><abbr class="published" title="<?php the_time(\'Y-m-dTH:i:sO\') ?>"><?php the_time( get_option( \'date_format\' ) ); ?></abbr></span>
                        <?php edit_post_link( __( \'Edit\', \'your-theme\' ), \'<span class="meta-sep">|</span><span class="edit-link">\', \'</span>\' ); ?>
                    </div><!-- .entry-meta -->
    <?php /* The entry content */ ?>
                    <div class="entry-content">
<?php the_content( __( \'Continue reading <span class="meta-nav">&amp;raquo;</span>\', \'your-theme\' )  ); ?>
<?php wp_link_pages(\'before=<div class="page-link">\' . __( \'Pages:\', \'your-theme\' ) . \'&amp;after=</div>\') ?>
                    </div><!-- .entry-content -->
                    <?php /* Microformatted category and tag links along with a comments link */ ?>
                    <div class="entry-utility">
                        <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e( \'Posted in \', \'your-theme\' ); ?></span><?php echo get_the_category_list(\', \'); ?></span>
                        <span class="meta-sep"> | </span>
                        <?php the_tags( \'<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">\' . __(\'Tagged \', \'your-theme\' ) . \'</span>\', ", ", "</span><span class="meta-sep">|</span>" ) ?>
                        <span class="comments-link"><?php comments_popup_link( __( \'Leave a comment\', \'your-theme\' ), __( \'1 Comment\', \'your-theme\' ), __( \'% Comments\', \'your-theme\' ) ) ?></span>
                        <?php edit_post_link( __( \'Edit\', \'your-theme\' ), \'<span class="meta-sep">|</span><span class="edit-link">\', \'</span>\' ); ?>
                    </div><!-- #entry-utility -->
                </div><!-- #post-<?php the_ID(); ?> -->

<?php /* Close up the post div and then end the loop with endwhile */ ?>
    </div><!-- #content -->

</div><!-- #container -->

<div id="primary" class="widget-area">
</div><!-- #primary .widget-area -->

<div id="secondary" class="widget-area">
</div><!-- #secondary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
如何修复此问题?

2 个回复
SO网友:Anjum

在下面的语句之外使用单引号,为什么会出现此错误,因为类属性使用了双引号"</span><span class="meta-sep">|</span>" 并用双引号将其括起来。

替换此

"</span><span class="meta-sep">|</span>"

具有

\'</span><span class="meta-sep">|</span>\'

反之亦然

"</span><span class=\'meta-sep\'>|</span>"

<?php the_tags( \'<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">\' . __(\'Tagged \', \'your-theme\' ) . \'</span>\', \', \', \'</span><span class="meta-sep">|</span>\' ) ?>

SO网友:Howdy_McGee

请在第31行尝试此操作,您的报价不一致:

<?php the_tags( \'<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">\' . __(\'Tagged \', \'your-theme\' ) . \'</span>\', \', \', \'</span><span class="meta-sep">|</span>\' ) ?>

结束

相关推荐

Displaying oEmbed errors?

有时,通过oEmbed嵌入项目是不可能的,例如,当YouTube视频已禁用嵌入时。The oEmbed service will return a 401 Unauthorized, 并且不会转换代码。有没有办法通知用户这一点?当前的工作流是非直观的(至少对我来说),我更喜欢在WordPress页面上,或者更好的是,在编辑器中显示一条消息,说明对象无法嵌入。