2017-02-26 4 views
0

내 사이트에서 특정 키워드가있는 여러 이미지로 구성된 갤러리를 게시하고 싶습니다. 특정 위치 또는 시간과 같습니다. WordPress의 캡션 옵션이나 설명 옵션을 사용하려고 생각했습니다. 이미지에는 "위치" "일몰"과 같은 더 많은 키워드가 있습니다. 나는이 What is the function got get all the media files wordpress?https://wordpress.org/ideas/topic/functions-to-get-an-attachments-caption-title-alt-description와 결합하여 사용하려고 시도했지만 작동하지 않습니다. 도와 줄수있으세요. 하지만 초보자가 그래서 당신이 내가 내 page-name.php이미지가 e 키워드로만 게시됩니다.

+1

언급 된 두 링크의 정보를 사용한 후 코드가 어떻게 보이는지 보여주십시오. – RST

+0

' 에코 do_shortcode ('갤러리 열 = "4"링크 = "파일"ids = " ] ') ​​ '이것은 내 page-name.php에 지금 있습니다. –

+0

게시물에 추가 할 수 있습니까? 이렇게하면 더 쉽게 읽을 수 있습니다. – RST

답변

0
<?php $attachment_meta = wp_get_attachment(wp_get_attachement_id()); ?>        
<?php if ($attachement_meta[caption] == 'Ceahlau') ?> 
echo do_shortcode('[gallery columns="4" link="file" ids=" <?php   
wp_get_attachement_id() ?>"]') 
<?php else: ?> 
<?php endif; ?>' 
This is what i have now in my page-name.php 
0
This is what i have now in my page-name.php 
    <?php 

    $args = array(
    'post_type' => 'attachment', 
    'numberposts' => -1, 
    'post_status' => null, 
    'post_parent' => null, // any parent 
    'post_mime_type' => 'image' 

); 
$attachments = get_posts($args); 
    if ($attachments) { 
    $attachment_meta = wp_get_attachment($attachment->ID); 
      foreach ($attachments as $post) { 
      if ($attachment_meta['caption'] == 'Ceahlau'){ 
      setup_postdata($post); 
       echo wp_get_attachment_image($attachment->ID, 'full'); 
       the_attachment_link($post->ID, false); 

          } 
       } 
} 

?> 
지금 무엇을 가지고

LE: <?php $attachment_meta = wp_get_attachment(wp_get_attachement_id()); ?> 
    <?php if ($attachement_meta[caption] == 'Ceahlau') ?> 
    echo do_shortcode('[gallery columns="4" link="file" ids=" <?php wp_get_attachement_id() ?>"]') 
<?php else: ?> 
<?php endif; ?> 

페이지 name.php에 쓸 정확히 function.php에 쓸 무엇을 설명 할 수입니다

+0

이 기능을 사용하면 도움이 될 수 있습니까? –