ACF Photo Gallery Field でEdit Imageからカスタムクラスを記載して、固定ページのテンプレートに反映させたいんですが、できません。
サンプルソースに太字部分を記述すれば、表示されるはずのような気がするんですが、うまくいかず。。。
プラグインページURL
https://ja.wordpress.org/plugins/navz-photo-gallery/
ソース
<?php echo $class; ?>の値が反映されない?<?php //Get the images ids from the post_metadata $images = acf_photo_gallery('vacation_photos', $post->ID); //Check if return array has anything in it if( count($images) ): //Cool, we got some data so now let's loop over it foreach($images as $image): $id = $image['id']; // The attachment id of the media $title = $image['title']; //The title $caption= $image['caption']; //The caption $full_image_url= $image['full_image_url']; //Full size image url $full_image_url = acf_photo_gallery_resize_image($full_image_url, 262, 160); //Resized size to 262px width by 160px height image url $thumbnail_image_url= $image['thumbnail_image_url']; //Get the thumbnail size image url 150px by 150px $url= $image['url']; //Goto any link when clicked $target= $image['target']; //Open normal or new tab $alt = get_field('photo_gallery_alt', $id); //Get the alt which is a extra field (See below how to add extra fields) $class = get_field('photo_gallery_class', $id); //Get the class which is a extra field (See below how to add extra fields) ?> <div class="col-xs-6 col-md-3"> <div class="thumbnail <?php echo $class; ?>"> <?php if( !empty($url) ){ ?><a href="https://wordpress.org/plugins/navz-photo-gallery/<?php echo $url; ?>" <?php echo ($target == 'true' )? 'target="_blank"': ''; ?>><?php } ?> <img src="https://wordpress.org/plugins/navz-photo-gallery/<?php echo $full_image_url; ?>" alt="<?php echo $title; ?>" title="<?php echo $title; ?>"> <?php if( !empty($url) ){ ?></a><?php } ?> </div> </div> <?php endforeach; endif; ?>
できません。うまくいきませんでは、どのような問題が発生しているのかわかりませんので、発生している内容を具体的に記載してください。
例:エラーメッセージが表示される。 〇〇が表示される。 真っ白な画面になる。など。
また、真っ白な画面の場合やエラーが出ている場合は、Webサーバーのログも確認して、どのようなメッセージが出ているか確認してください。
<?php echo $class; ?>で、値が反映されないです。
プラグインページのサンプル通りに記載していて、変数の値が出てこないということです。
エラーや意図しないデータの表示、ホワイトアウトはないです。
(あれば記述の不備だとわかるので、おそらく質問しません)
webサーバーのログは調べてません。
プラグインページを見ると、変数の宣言がある割に、アウトプットのサンプルが見当たらないので、
そもそも機能していないのではないかとも思っています。
同じプラグイン使っている人が、解決法をご存知ではないかと質問してみた次第です。
回答1件
あなたの回答
tips
プレビュー