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

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

    <?php $i=0;?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $i++;?>
    <div class="cols"<? if($i%3==0) echo ' style="margin-right:0"';?>>
        <div class="post" id="post-<?php the_ID(); ?>">
            <?php $thumb=get_post_meta($post->ID, 'image', true); ?>
            <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
            <?php if($thumb!=''){
            $thumb = str_replace(get_bloginfo('url').'/','',$thumb);
            ?>
            <img src="<?php bloginfo('template_url');?>/thumb.php?src=<?=$thumb;?>&w=183&h=140&zc=1" class="thumb" alt="<?php the_title(); ?>" />
            <? } else { ?>
            <img src="<?php bloginfo('template_url'); ?>/images/pic.jpg" alt="" class="thumb" />
            <? } ?>
            </a>

            <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo cut_string(get_the_title(),30,'...'); ?></a></h2>
            <p><?php echo cut_string(get_the_content(),60,'...'); ?></p>
            <p class="meta">
            <?php if(function_exists('the_views')) { ?>
            <span class="views"><?php the_views(); ?></span> <?php } ?>
            <?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'comments'); ?>
            </p>
            <p><?php if(function_exists('the_ratings')) { the_ratings(); } ?> </p>

        </div></div>

    <?php endwhile; ?>
    <div class="clearfix"></div>
    <div class="page_navi"><?php page_navi();?></div>

<?php else: ?>

    <div class="post">
        <h2 class="title">Not Found</h2>
    </div>

<?php endif; ?>
</div>

<!-- end content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

パースエラー:

構文エラー、36行目の/home/fakecsc1/domains/jocuri2k.com/public_html/wp-content/themes/Games/index.phpの予期しないT_ENDWHILE

このコードの何が問題になっていますか?どうすれば修正できますか?

4

1 に答える 1

15

問題はここでのショートタグの使用にあるようです:<?代わりに<?php

 <? } else { ?>
            <img src="<?php bloginfo('template_url'); ?>/images/pic.jpg" alt="" class="thumb" />
            <? } ?>
            </a>

サーバーがこれらをPHPとして解釈していない場合、phpはendwhilecloseタグを認識する前にbeforeを認識します。<?phpそれらをの代わりに変更します<?

于 2012-06-06T21:49:12.413 に答える