カスタムフィールドの値を表示する4つの方法

3.01 templates

投稿のmetaデータとして、カスタムフィールドを投稿に添付する事ができます

このフィールド名には、アンダーバーから始まる内部カスタムフィールドと、アンダーバーのない公開用カスタムフィールドがあります。

内部カスタムフィールドは、テンプレート関数 the_meta()では、出力しません

get_post_custom_keys($post_id)を使う事で、取得する事ができます。

<div class="field-note">
<?php 
	the_meta();
?>
</div>
<div class="field-note">
<?php

 	$keys= get_post_custom_keys($post_id);
	
	
	
	foreach($keys as $key){
	
		if(preg_match(" |^[^_]+ |",$key)){
			$meta_values= get_post_meta($post->ID, $key, false);
		
			if(is_array($meta_values)){
	
				echo implode("<br />",$meta_values);
			}else{
			
				echo $meta_values;
			
			}
		}
		

	}
?>
</div>	
<?php
	echo post_custom('poet');
?>
query_posts('meta_key=ICON&meta_value=01.gif');
…
wp_reset_query();

@see http://codex.wordpress.org/Template_Tags/query_posts#Custom_Field_Parameters

[emulsion_relate_posts]