サポート » テーマ » カスタム投稿の「 新着記事とアイキャッチの一覧 」を表示したい場合

  • トップページのお知らせなどで、新着記事のタイトルのとなりにアイキャッチを表示する場合、下記の方法で、投稿(post)のものは表示できました。

    <ul class="blog">
    <?php query_posts('showposts=6');
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink(); ?>" style="float:left; margin-right:10px;">
    <?php the_post_thumbnail(array(51,51)); ?></a>
    <a href="<?php the_permalink(); ?>" style="width:300px; padding-top:8px;"><?php the_title(); ?></a>
    </li>
    <?php endwhile; endif; wp_reset_query(); ?>
    </ul>

    この方法で、投稿(post)ではなく、カスタム投稿(仮に product-a )のタイトルとアイキャッチ画像を表示したい場合は、どう修正すれば良いのでしょうか?

    分かる方がいらっしゃいましたら、教えて頂けると幸いです。
    よろしくお願いいたします。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • ヒントをありがとうございます!
    私もカスタム投稿をトップに表示したく、
    タイトルと月日はでるものの、アイキャッチ画像の表示させたく
    the_post_thumbnail部分の記述方法を調べているところでした。

    私は以下で表示できました。

    <ul>
    <?php wp_nav_menu( array( 'menu' => ' /* 投稿タイプを指定 */ ' ) ); ?>
    <?php
    $args = array(
    'post_type' => '/* 投稿タイプを指定 */',
    'posts_per_page' => 10,
    'numberposts' => '-1',);
    $my_posts = get_posts($args);
    foreach ( $my_posts as $post ) {
    setup_postdata($post); ?>
    
    <li>
    <a href="<?php the_permalink(); ?>" style="float:left; margin-right:10px;">
    <?php the_post_thumbnail(array(51,51)); ?></a>
    <span class="post-date"><?php the_time("Y年m月j日") ?></span><br>
    <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
    
    <?php
    
    }
    
    ?>
    
            </ul>

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「カスタム投稿の「 新着記事とアイキャッチの一覧 」を表示したい場合」には新たに返信することはできません。