开发者

What's wrong with this code? (unexpected $end on last line) [closed]

开发者 https://www.devze.com 2023-02-11 04:34 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. 开发者_如何学运维 Closed 9 years ago.
<?php
/*
Template Name: Videos
*/
?>

<?php get_header();?>

    <section id="content">
        <section id="main">
            <?php 
                $c=0;
                $i=1;

                $temp = $wp_query;
                $wp_query = null;
                $wp_query = new WP_Query();
                $wp_query->query('post_type=videos' . '&paged=' . $paged . '&posts_per_page=16');

                while ( $wp_query->have_posts() ) : $wp_query->the_post(); $c++;
            ?>

            <?php if (have_posts()) : ?>

                <?php while (have_posts()) : the_post(); $c++; ?>
                    <article class="post<?php if($i%4 == 0) { echo ' right'; }; $i++; ?>" id="post-<?php the_ID(); ?>">
                        <section class="entry">
                            <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'video-thumb' ); } ?></a>
                        </section>
                        <section class="description">
                            <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                        </section>
                    </article>

                <?php
                    endwhile; 
                    wp_pagenavi();
                    $wp_query = null;
                    $wp_query = $temp;
                    wp_reset_query();
                ?>

                <?php if( $c < 16 ) : for ($dummy= $c; $dummy < 16; $dummy++) : ?>

                    <article class="post<?php if($i%4 == 0) { echo ' right'; }; $i++; ?>" id="post-<?php the_ID(); ?>">
                        <img src="<?php bloginfo('template_url'); ?>/images/dummy-video.gif" alt="Post coming soon!" />
                    </article>

                    <?php endfor;?>

                <?php endif;?>

            <?php endif; ?>

            <section id="map">
                <img src="<?php bloginfo('template_url') ?>/images/interactive-map.jpg" alt="Interactive Map" />
            </section>
        </section>

<?php get_sidebar(); ?>

    </section>

<?php get_footer(); ?>

Here's the pastebin version: http://pastebin.com/2Grja48U


I think you're missing endwhile; for the first while statement.


<?php while ( ... ) : ?>

    <section id="map">
        <img src="<?php bloginfo('template_url') ?>/images/interactive-map.jpg" alt="Interactive Map" />
    </section>

<?php endwhile; ?>

This'll fix it for you


It is exactly as the message says: the parser reached the end of file when it did not expect it (something, probably a while, hasn't been closed yet).

0

精彩评论

暂无评论...
验证码 换一张
取 消