我正在使用ACF照片库插件(添加图像库选项的ACF插件)。我正在尝试添加为特定图像提供自己的CSS类的选项,所有这些都是通过教程->https://wordpress.org/plugins/navz-photo-gallery/ (用法,添加额外字段),但不幸的是,由于某种原因,CSS类没有出现在代码中。我将注释代码粘贴到下面(没有太多)。我哪里出错了?
/// I put this to functions.php, in edition in particular image window appears with css class field
<?php
function my_extra_gallery_fields( $args, $attachment_id, $field ){
$args[\'class\'] = array(\'type\' => \'text\', \'label\' => \'Kolor produktu\', \'name\' => \'class\', \'value\' => get_field($field . \'_class\', $attachment_id) ); /// I think the problem may be here
return $args;
}
add_filter( \'acf_photo_gallery_image_fields\', \'my_extra_gallery_fields\', 10, 3 );
?>
/// I put this code to single-portfolio.php
<?php
$images = acf_photo_gallery(\'gallery_images\', $post->ID); /// gallery_images to slug pola galeria w ACF
if( count($images) ):
foreach($images as $image):
$full_image_url= $image[\'full_image_url\'];
$class = get_field(\'gallery_images_class\', $id);
endforeach; endif;
?>
/// This code displays image, CSS class should appers, but it doesn\'t
<?php foreach($images as $image) { ?>
<img src="<?php echo $image[\'full_image_url\']; ?>" class="<?php echo $class; ?>" >
<?php } ?>