2017-02-26 29 views
0

自分のサイトから特定のキーワードを持つ多数の画像で構成されたギャラリーを投稿したいと思います。特定の場所や時間のように。私はキャプションのオプションやWordPressの説明オプションを使用すると思った。画像には、「場所」「夕焼け」など、より多くのキーワードがあります。私はこれをと組み合わせてWhat is the function got get all the media files wordpress?と組み合わせて使用​​しようとしましたが、動作しません。私を助けてください。しかし、私はあなたが 投稿画像のみeキーワードで投稿する

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に書き込むために、何書くために説明することができます。これは私が私の page-name.php

+1

上記の2つのリンクの情報を使用した後に、コードがどのように表示されるかを教えてください。 – RST

+0

'<?php $ attachment_meta = wp_get_attachment(wp_get_attachement_id()); ?> <?php if($ attachement_meta [caption] == 'Ceahlau')?> echo do_shortcode( 'ギャラリー列= "4"リンク= "ファイル" ids = "<?php wp_get_attachement_id()?>" ] ') <?php else:?> <?php endif; ?> 'これは今私のページ名.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); 

          } 
       } 
} 

?> 
に今持っているものです初心者です
+0

この機能を手伝ってもらえますか?私はスタックしています –

関連する問題