0

这是我第一次使用 Wordpress 模板,也是我第一次使用 PHP(除了偶尔包含的服务器)。也就是说,我对PHP一无所知,只是对语法一无所知。

我正在尝试创建一些自定义循环,一旦我开始工作,我只需复制粘贴工作代码,更改 ID,并期望它可以工作。可能是傻?无论如何,我在第 203 行得到了一个意想不到的 $end 。

有谁愿意告诉我是什么原因造成的?提前致谢!

<!-- 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] &middot; by [entry-author] &middot; in [entry-terms taxonomy="category" before=""] [entry-edit-link before=" &middot; "]', '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] &middot; by [entry-author] &middot; in [entry-terms taxonomy="category" before=""] [entry-edit-link before=" &middot; "]', '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-->
4

1 回答 1

3

您拥有的最后一行 php 代码是:

   <?php else : ?>

你需要完成那个控制结构。您缺少以下内容:

   <?php endif; ?>
于 2012-05-17T18:04:30.230 回答