カスタム投稿タイプ 一覧表示関数

 /**
  * カスタムポストタイプ 一覧出力
  *
  * index.php等に、以下のコードを追加することで表示
  *
  * <?php get_header(); ?>
  *		<div id="container">
  *			<div id="content">
  * …
  * <?php my_extend_post("coupons");?>
  *		…
  * $type string or array()
  */
 add_theme_support('post-thumbnails');
 
 function my_extend_post($type="coupons",$count=5){
 
 
 	$loop= new WP_Query( array( 'post_type'=> $type, 'posts_per_page'=> $count ) );
 	
 	while ( $loop->have_posts() ) : $loop->the_post(); ?>
 
 		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 			
 			<h2 class="entry-title">
 <?php
 	
 	/**
 	 * アイキャッチ画像のサムネール表示
 	 *
 	 *
 	 *
 	 *
 	 */
 
 	if ( has_post_thumbnail() ) {
 		the_post_thumbnail(array(32,32));
 	} else {
 		echo "<img src=\"http://tenman.info/images/pen.jpg\" style=\"width:32px;\" alt=\"default-icon\" />";
 	}
 	
 	/**
 	 * アイキャッチ画像のサムネール表示
 	 *
 	 *
 	 *
 	 *
 	 */
 	
 	
 echo wp_get_attachment_thumb_url( $post_ID );
 	
 	
 	/**
 	 * グラバタの表示サンプル
 	 *
 	 *
 	 *
 	 * see:http://codex.wordpress.org/Function_Reference/get_bloginfo
 	 */
 
 
 	$email= get_bloginfo("admin_email");
 	
 	if (function_exists('get_avatar')) {
 		 echo get_avatar($email,32);
 	 } else {
 		 //alternate gravatar code for < 2.5
 		 $grav_url= "http://www.gravatar.com/avatar/" . 
 			 md5(strtolower($email)) . "?d=&s=32";
 		 echo "<img src='$grav_url'/>";
 	 }
 
 
  
 
 /**
  * カスタムポストタイトル表示、個別ページ(single.php)遷移リンク
  *
  *
  *
  *
  */
  ?>
 <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
 			</h2>
 <?php
 /**
  * Posted by hoge の表示
  *
  *
  *
  * 
  */
 ?>
 			<div class="entry-meta">
 				<?php twentyten_posted_on(); ?>
 			</div><!-- .entry-meta -->
 <?php
 /**
  * コンテンツ
  *
  *
  *
  *
  */
 ?>
 			<div class="entry-content">
 			<?php the_content(); ?>
 			</div>
 		</div>
 <?php 
 	endwhile; 
 }
 
 /**
  * twentyten functions.phpが後から読み込みのため、調整のためコピー
  *
  *
  *
  *
  */
 
 if ( ! function_exists( 'twentyten_posted_on' ) ) :
 /**
  * Prints HTML with meta information for the current post—date/time and author.
  *
  * @since Twenty Ten 1.0
  */
 function twentyten_posted_on() {
 	printf( __( '<span %1$s>Posted on</span> %2$s by %3$s', 'twentyten' ),
 		'class="meta-prep meta-prep-author"',
 		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">',
 			get_permalink(),
 			esc_attr( get_the_time() ),
 			get_the_date()
 		),
 		sprintf( '</span> <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
 			get_author_posts_url( get_the_author_meta( 'ID' ) ),
 			sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
 			get_the_author()
 		)
 	);
 }
 endif;

 

[emulsion_relate_posts]