0
这是我第一次搞乱Wordpress模板和我第一次使用PHP(除了偶尔的服务器包括)。也就是说,我对PHP一无所知,只能掌握语法。
我想创建一些自定义的循环,一旦我得到一个工作,我只需复制粘贴的工作代码,更改了ID,并希望工作。傻或许?无论如何,我得到一个意外的$ 203行。
任何人愿意告诉我是什么原因造成的?提前致谢!
<!-- FEATURED LOOP -->
<div class="featured">
<?php $my_query = new WP_Query('category_name=featured&showposts=1'); ?>
<?php if (have_posts()) : ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php do_atomic('before_entry'); // origin_before_entry ?>
<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
<?php do_atomic('open_entry'); // origin_open_entry ?>
<?php
if (current_theme_supports('get-the-image')) {
if (is_sticky ($post->ID)) {
get_the_image(array('meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'image_class' => 'featured'));
} else {
get_the_image(array('meta_key' => 'Thumbnail', 'size' => 'thumbnail', 'image_class' => 'featured'));
}
}
?>
<div class="sticky-header">
<?php echo apply_atomic_shortcode('entry_title', '[entry-title]'); ?>
<?php echo apply_atomic_shortcode('byline', '<div class="byline">' . __('[entry-published] · by [entry-author] · in [entry-terms taxonomy="category" before=""] [entry-edit-link before=" · "]', 'origin') . '</div>'); ?>
</div><!-- .sticky-header -->
<div class="entry-summary">
<?php the_excerpt(); ?>
<?php wp_link_pages(array('before' => '<p class="page-links">' . __('Pages:', 'origin'), 'after' => '</p>')); ?>
</div><!-- .entry-summary -->
<?php do_atomic('close_entry'); // origin_close_entry ?>
</div><!-- .hentry -->
<?php do_atomic('after_entry'); // origin_after_entry ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
<?php else : ?>
<!--END FEATURED LOOP-->
<!-- SUBFEATURED LOOP -->
<div class="subfeatured">
<?php $my_query = new WP_Query('category_name=subfeatured&showposts=1'); ?>
<?php if (have_posts()) : ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php do_atomic('before_entry'); // origin_before_entry ?>
<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
<?php do_atomic('open_entry'); // origin_open_entry ?>
<?php
if (current_theme_supports('get-the-image')) {
if (is_sticky ($post->ID)) {
get_the_image(array('meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'image_class' => 'featured'));
} else {
get_the_image(array('meta_key' => 'Thumbnail', 'size' => 'thumbnail', 'image_class' => 'featured'));
}
}
?>
<div class="sticky-header">
<?php echo apply_atomic_shortcode('entry_title', '[entry-title]'); ?>
<?php echo apply_atomic_shortcode('byline', '<div class="byline">' . __('[entry-published] · by [entry-author] · in [entry-terms taxonomy="category" before=""] [entry-edit-link before=" · "]', 'origin') . '</div>'); ?>
</div><!-- .sticky-header -->
<div class="entry-summary">
<?php the_excerpt(); ?>
<?php wp_link_pages(array('before' => '<p class="page-links">' . __('Pages:', 'origin'), 'after' => '</p>')); ?>
</div><!-- .entry-summary -->
<?php do_atomic('close_entry'); // origin_close_entry ?>
</div><!-- .hentry -->
<?php do_atomic('after_entry'); // origin_after_entry ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
<?php else : ?>
<!--END SUBFEATURED LOOP-->
通常,这个错误表明你错过了循环的结束(for,foreach,while,if)。你可以检查203行之前/之后看看是否是这种情况?要排除这一切,没有行号,有点困难。 – tcole
投票结束为本地化。从[4,000多个其他问题]中可以很容易地知道这个错误的含义(http://stackoverflow.com/search?q=%5Bphp%5D+Unexpected+%24End+Error)。某处存在不匹配的控制结构。 –
如果用'<?php endif;替换代码中的两个'<?php else:?>'行, “你应该很好走。” –