サポート » テーマ » endifを使用するとエラーが出ます

  • 解決済 engelhearts

    (@engelhearts)


    お世話になってます。
    テーマの編集でindex.phpを編集しているのですが、
    is_home()やis_single()などのif文を使用するとき、endif;を記入するとエラーが出ます。

    Parse error: syntax error, unexpected T_ENDIF in wp/wp-content/themes/sample_wp/index.php on line 34

    以下ソースです。

    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
    <html xmlns=”http://www.w3.org/1999/xhtml”&gt;
    <head>
    <meta http-equiv=”Content-Type” content=”<?php bloginfo(‘html_type’); ?>; <?php bloginfo(‘charset’); ?>” />
    <title><?php bloginfo(‘name’); ?></title>
    <link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” />
    </head>

    <body>
    <!– ヘッダー –>
    <div id=”container”>
    <div id=”header”>
    <h1><a href=<?php echo home_url(); ?>><?php bloginfo(‘name’) ?></h1>
    <p id=”desc”><?php bloginfo(‘description’); ?></p>
    </div>
    <!– コンテンツ –>
    <div id=”content”>
    <?php if(have_posts()): while(have_posts()): the_post(); ?>
    <div class=”post”>
    <h2><a href=<?php the_permalink(); ?>><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <p class=”postinfo”>
    <?php echo get_the_date(); ?><?php the_time(); ?>
    |
    カテゴリー:<?php the_category(‘, ‘); ?>
    </p>
    </div>
    <?php if(is_single()); ?>
    <p class=”pageLink”>
    <span class=”oldpage”><?php previous_post_Link(); ?></span>
    <span class=”newpage”><?php next_post_Link(); ?></span>
    </p>
    <?php endif; ?>

    <?php endwhile; endif; ?>
    </div>
    </div>
    </body>
    </html>

    何度か打ち直して、試してみてもendifでエラーが出てしまいます。
    本来なら自分で解決すべきことですが、力を貸していただければ幸いです。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • 28行目当たりの

    <?php if(is_single()); ?>
    <p class="pageLink">
    <span class="oldpage"><?php previous_post_Link(); ?></span>
    <span class="newpage"><?php next_post_Link(); ?></span>
    </p>
    <?php endif; ?>


    <?php if(is_single()); ?>
    セミコロンになっているのでそれをコロンに変えてみるのはいかがでしょうか。

    トピック投稿者 engelhearts

    (@engelhearts)

    if文の最後をセミコロンからコロンに変えたところ出来ました!
    的確なご指摘で大変助かりました。ありがとうございます。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「endifを使用するとエラーが出ます」には新たに返信することはできません。