私はワードプレスにあまり詳しくありませんが、ワードプレス プラットフォームを使用できるように、レイアウトをテーマとして作成することに取り組んでいます。何らかの理由で、_post_thumbnail 関数が機能しません。私はすでに追加しました
add_theme_support( 'post-thumbnails' );
私の functions.php ファイルに、はい、注目の画像を設定し、the_post_thumbnail(); を含めました。ループの中。
私は何を間違っていますか?実際の関数を調べてみたところ、wp_get_attachment_image_src() 関数を参照しているときに wp_get_attachment_image() 関数の $image 変数に問題があることがわかりました。$image が空であってはならないはずなのに、空です。post_thumbnail id は問題なく取得できるので、画像セットがあることはわかっています。それはただのことを表示しません。
カスタムテーマをゼロから書いているので、functions.php には add_theme_support( 'post-thumbnails' ); しかありません。気になる方は今すぐどうぞ。
編集:
ここに私のループがあります:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="home-entry clearfix" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" >
<?php
if (has_post_thumbnail()) {
the_post_thumbnail();
} else {
echo '<img class="home-thumb trans-border" src="' . catch_first_image() . '" width="200px" height="150px" title="' . the_title() . '" />';
}
?>
</a>
<div class="home-post">
<div class="home-meta">Posted <?php the_time('M j, Y'); ?> - <?php the_category(' , ') ?> - <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></div>
<h2 class="post-title">
<a href="<?php the_permalink(); ?>" title="Permanent Link to <?php the_title_attribute(); ?>" rel="bookmark" class="title"><?php the_title(); ?></a>
<a class="read" href="<?php the_permalink(); ?>" title="Read More">Read More</a>
</h2>
<div class="home-excerpt">
<?php the_excerpt(); ?>
</div>
</div>
</div>
<?php endwhile; ?>
<?php echo paginate_links() ?>
<?php else : ?>
<h2>Nothing Found</h2>
<?php endif; ?>
続き:
そこで、注目の画像をサポートするテーマを見つけて、ループのその部分を正確にコピーしましたが、まだ何もコピーしていません:
<?php if(has_post_thumbnail()) {
echo '<span class="thumbnail"><a href="'; the_permalink(); echo'">';the_post_thumbnail(array(100,100)); echo '</a></span>';
} else {
$image = evlget_first_image();
if ($image):
echo '<span class="thumbnail"><a href="'; the_permalink(); echo'"><img src="'.$image.'" alt="';the_title();echo'" /></a></span>';
endif;
} ?>
それで、それは一体何でしょうか?私は困惑している...