• 解決済 seabow

    (@seabow)


    初めまして。
    いろいろな記述を参考に
    色々挑戦してみたのですが、どーやっても
    自力で解決できずにここで相談させて頂きたいと思います。

    記事抜粋で使用するthe_excerptですが、
    index.php内に記述させたところなぜか
    表示がされず困っております。

    どなたかご教授下さいますでしょうか?
    〜現在記述〜

    <h2>更新情報</h2> </div>
    
    <?php $posts = get_posts('numberposts=5'); ?>
    <?php foreach($posts as $post): ?>
    
    <div id="archiveindex" class="odd link">
    <div class="archiveindex_entry">
    <div class="archiveindex_entry_left">
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(120,100), array('class' => 'left')); ?></a></div>
    
    <div class="archiveindex_entry_right">
    
    <h4 class="mainindex_entrytitle"><a href="<?php the_permalink(); ?>">
    <?php the_title(); ?></a></h4>
    <div class="archiveindex_entry_text"><a href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a>
    </div>
    </div>

    下から3段目のthe_excerptの記述を施しているのですが、
    表示されません。

    もちろんWP MultibytePatchの有効化はしておりますし
    configファイルのリネームもした上で症状改善が
    見られません。

    お分かりになられる方、いらっしゃいましたら
    何卒お願い致します。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • seabowさん

    foreach($posts as $post):

    の後に

    setup_postdata($post);

    がないからではないでしょうか? ちなみに、確認になりますが

    <?php foreach($posts as $post): ?>

    の対になる

    <?php endforeach; ?>

    は、示されたコードの後に書かれているんですよね?(そもそもなければエラーになりますし)

    テンプレートタグ/get posts – WordPress Codex 日本語版

    トピック投稿者 seabow

    (@seabow)

    >tecking様

    ご教授ありがとう御座います。
    tecking様のおっしゃって頂いたsetup_postdataの
    記述で一発解決致しました。

    ありがとう御座います!

    ちなみにもちろんですが、
    <?php endforeach; ?>
    は記述してございます。

    本当に勉強になりました!
    ありがとう御座います!

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「the_excerptの記述について」には新たに返信することはできません。