1
私はWordpressの新機能です。各カテゴリの最初のエントリに投稿の画像を表示する方法を知りたいと思います。他の項目はタイトルと説明のみを表示します。現在、このコードを持っています。Wordpress - ループ内の最初の投稿にのみサムネイルを表示しますか?
<?php if (have_posts()) : ?>
<section>
<?php echo do_shortcode("[soliloquy slug='categorias']"); ?>
<div style="clear:both; height:10px; margin:0 0 20px;"></div>
<?php while (have_posts()) : the_post(); ?>
<article>
<header>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<time datatime="<?php the_time('F j, Y'); ?>"><i class="fa fa-clock-o"></i> <?php the_time('j F, Y'); ?> | Publicado en: <?php the_category(', ') ?></time>
</header>
<figure class="category">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="Leer la nota <?php the_title_attribute(); ?>">
<?php
// Must be inside a loop.
if (has_post_thumbnail($_post->ID)) {
echo '<a href="' . get_permalink($_post->ID) . '" title="' . the_title_attribute(array('echo' => 0)) . '">';
echo get_the_post_thumbnail($_post->ID, 'medium');
echo '</a>';
}
else {
echo '<img src="http://www.changoonga.com/wp-content/uploads/2016/10/no-foto.jpg" title="no hay foto" />';
} ?>
</a>
</figure>
<div class="cat-excerpt"><?php the_excerpt(); ?></div>
<div style="clear:both; height:0px; margin:0"></div>
</article>
<?php endwhile; ?>
<div class="pagination">
<span><?php next_posts_link('« Notas anteriores'); ?></span>
<span><?php previous_posts_link('Notas recientes »'); ?></span>
</div>
</section>
<?php else : ?>
<p><?php _e('Ups!, no hay entradas.'); ?></p>
<h2>Puedes ver lo más reciente o intentar con otra búsqueda</h2>
<?php echo do_shortcode("[display-posts posts_per_page='10' image_size='medium' include_excerpt='true']"); ?>
<?php endif; ?>
私の悪い英語のために申し訳ありません!
解決済み!どうもありがとうございました! – K1X3