サポート » 使い方全般 » index.phpにサムネイルを出したい

  • 解決済 mono0517

    (@mono0517)


    新着だけTOPに出ます

    <?php get_header(); ?>
      <section id="News">
        <article>
          <dl>
            <?php $paged = get_query_var('paged'); ?>
            <?php
    			 $args = array(
     			'post_type' => array('post'),
     			'posts_per_page' => 5,
     			'paged' => $paged
     			);
     		?>
            <?php if(have_posts()):   query_posts($args);?>
            <?php while(have_posts()): the_post(); ?>
            <dt><?php the_time('Y.m.d'); ?></dt>
            <dd><a href="<?php the_permalink(); ?>"><?php the_title() ?><br /><?php	the_post_thumbnail();	?></a>
            </dd>
            <?php endwhile; ?>
          </dl>
          <?php	endif; ?>
        </article>
      <?php if(function_exists('wp_pagenavi')): ?>
      <div class="both20"></div>
      <div class="center">
      <div class="pagenavi">
        <?php wp_pagenavi(); ?>
      </div>
    </div>
      <?php endif; ?>
    	</section>
    <?php get_footer(); ?>

    このように記述しましたが、サムネイルが出ません。
    出したいのはPDFをアイキャッチにしたものです。
    function.phpには

    function save_default_thumbnail( $post_id ) {
    	if ( !wp_is_post_revision( $post_id ) ) {
    		$post_thumb = get_post_meta( $post_id, '_thumbnail_id', true );
    		if ( empty($post_thumb) ) { // no featured image
    			$attaches =& get_posts ( 'post_parent='.$post_id.'&numberposts=1&post_type=attachment&post_mime_type=image&orderby=menu_order&order=ASC' );
    			if ( $attaches ):
    				update_post_meta( $post_id, '_thumbnail_id', $attaches[0]->ID );
    				return;
    			endif;
    		}
    	}
    }
    add_action( 'save_post', 'save_default_thumbnail' );

    と記載しました。
    プラグインでPDF Image Generatorを入れています。

  • トピック「index.phpにサムネイルを出したい」には新たに返信することはできません。