FAQ

Just another 仙台入門new weblog

­

カスタムフィールドの「値だけ表示する」

2009年 5月 27日 admin

post_custom()

the_meta()によって、すべてのカスタムフィールドのキーと値が表示されているときには、


<?php echo post_custom('key'); ?>を使う方法があります。

また、複数(の可能性がある)カスタムフィールドを表示する場合は、以下のようにしてもよいかもしれない。

 
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<?php
$mywords = post_custom('key');
 
if ( is_array($mywords) ) {
		echo implode($separator, $mywords );
	} else {
		echo $mywords ;
	}
 
<?php endwhile; endif; ?>
.
© FAQ Entries (RSS) and Comments (RSS)