저는 PHP에서 꽤 희망이 없기 때문에 약간의 도움을 요청했습니다!여러 워드 프레스 커스텀 포스트 메타 값
저는 WordPress를 daviesmusic.com에 음악 대행사 사이트의 CMS로 사용하고 있으며 사용자 지정 필드를 통해 다양한 아티스트에 대한 추가 정보가 많이 있습니다. 지금까지, 난 그냥과 같이, 사용자 정의 필드가 하나씩 값을 검색했습니다이 잘 작동
<?php
//audio title
$audio_title = get_post_meta($post->ID, 'audio_name', true);
if ($audio_title) :
?>
<p><?php echo $audio_title; ?></p>
만 나는 모든 다른 출력을 요구하는 사용자 정의 필드 많이 있습니다. 코드의
<?php
//profile image
$profile_pic = get_post_meta($post->ID, 'profileimage', true);
if($profile_pic) :
?>
<img class="post-thumb-single" src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $profile_pic; ?>&a=t&h=278&w=278&zc=1" alt="<?php the_title(); ?>" />
<?php
endif;
//photographer
$photographer = get_post_meta($post->ID, 'photographer', true);
if($photographer) :
?>
<p id="photographer">Photographer: <b><?php echo $photographer; ?></b></p>
<?php
endif;
//audio title
$audio_title = get_post_meta($post->ID, 'audio_title', true);
if ($audio_title) :
?>
<h4 class="nsmb">Audio files</h4>
<p><?php echo $audio_title; ?></p>
<?php
//audio file
$audio = get_post_meta($post->ID, 'audiofile', true);
if ($audio) :
?>
<p class="audio" id="audioplayer_1">Sorry, there was a problem loading the file.</p>
<script>AudioPlayer.embed("audioplayer_1", {soundFile: "<?php echo $audio; ?>"});</script>
<?php
$audio_credits_1 = get_post_meta($post->ID, 'audio_credits_1', true);
if ($audio_credits_1) :
?>
<p class="audio_cred"><?php echo $audio_credits_1; ?></p>
<?php
endif; endif; endif;
?>
로트 : 나는 예를 들어 작가의 사진, 오디오 파일, 오디오 파일의 제목과 너무 같은 오디오 파일에 대한 몇 가지 메모를해야합니다. 값을 검색하는 더 효율적인 방법이 있어야합니다! 어떤 아이디어?
건배
키 배열을 허용하는 함수로 마무리하고 키에 따라 적절한 HTML을 출력합니까? 예를 원하십니까? – t31os