【发布时间】:2014-09-10 10:57:18
【问题描述】:
我正在使用高级自定义文件插件MY Site的所有可能性在自定义模板中处理此站点 我创建了一些自定义字段并使用以下代码调用了字段值。
<div class="category-images"><?php echo get_field( "category_heading_1" ); ?></div>
<div class="images">
<?php
$image1 = get_field('image_1');
$image2 = get_field('image_2');
$image3 = get_field('image_3');
$image4 = get_field('image_4');
$image5 = get_field('image_5');
$image6 = get_field('image_6');
$image7 = get_field('image_7');
$image8 = get_field('image_8');
$image9 = get_field('image_9');
?>
<div class="img1"><a href="<?php echo get_field( "image_link_1" ); ?>"><img src="<?php echo $image1['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_2" ); ?>"><img src="<?php echo $image2['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_3" ); ?>"><img src="<?php echo $image3['url']; ?>" /></a></div>
</div>
<div class="images_txt">
<div class="img_txt"><b><?php echo get_field( "image_heading_1" ); ?></b> </div>
<div class="img_txt1"><b><?php echo get_field( "image_heading_2" ); ?></b> </div>
<div class="img_txt2"><b><?php echo get_field( "image_heading_3" ); ?></b> </div>
</div>
<div class="images">
<div class="img1"><a href="<?php echo get_field( "image_link_4" ); ?>"><img src="<?php echo $image4['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_5" ); ?>"><img src="<?php echo $image5['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_6" ); ?>"><img src="<?php echo $image6['url']; ?>" /></a></div>
</div>
<div class="images_txt">
<div class="img_txt"><b><?php echo get_field( "image_heading_4" ); ?> </b></div>
<div class="img_txt1"><b><?php echo get_field( "image_heading_5" ); ?> </b></div>
<div class="img_txt2"><b><?php echo get_field( "image_heading_6" ); ?> </b></div>
</div>
<div class="images">
<div class="img1"><a href="<?php echo get_field( "image_link_7" ); ?>"><img src="<?php echo $image7['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_8" ); ?>"><img src="<?php echo $image8['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_9" ); ?>"><img src="<?php echo $image9['url']; ?>" /></a></div>
</div>
<div class="images_txt">
<div class="img_txt"><b><?php echo get_field( "image_heading_7" ); ?> </b></div>
<div class="img_txt1"><b><?php echo get_field( "image_heading_8" ); ?></b> </div>
<div class="img_txt2"><b><?php echo get_field( "image_heading_9" ); ?></b> </div>
</div>
<div class="category-images"><?php echo get_field( "category_heading_2" ); ?></div>
<div class="images">
<?php
$image_21 = get_field('image_2(1)');
$image_22 = get_field('image_2(2)');
$image_23 = get_field('image_2(3)');
$image_24 = get_field('image_2(4)');
$image_25 = get_field('image_2(5)');
$image_26 = get_field('image_2(6)');
$image_27 = get_field('image_2(7)');
$image_28 = get_field('image_2(8)');
$image_29 = get_field('image_2(9)');
?>
<div class="img1"><a href="<?php echo get_field( "image_link_2(1)" ); ?>"><img src="<?php echo $image_21['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_2(2)" ); ?>"><img src="<?php echo $image_22['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_2(3)" ); ?>"><img src="<?php echo $image_23['url']; ?>" /></a></div>
</div>
<div class="images_txt">
<div class="img_txt"><b><?php echo get_field( "image_heading_2(1)" ); ?></b> </div>
<div class="img_txt1"><b><?php echo get_field( "image_heading_2(2)" ); ?></b> </div>
<div class="img_txt2"><b><?php echo get_field( "image_heading_2(3)" ); ?></b> </div>
</div>
<div class="images">
<div class="img1"><a href="<?php echo get_field( "image_link_2(4)" ); ?>"><img src="<?php echo $image_24['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_2(5)" ); ?>"><img src="<?php echo $image_25['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_2(6)" ); ?>"><img src="<?php echo $image_26['url']; ?>" /></a></div>
</div>
<div class="images_txt">
<div class="img_txt"><b><?php echo get_field( "image_heading_2(4)" ); ?> </b></div>
<div class="img_txt1"><b><?php echo get_field( "image_heading_2(5)" ); ?> </b></div>
<div class="img_txt2"><b><?php echo get_field( "image_heading_2(6)" ); ?> </b></div>
</div>
<div class="images">
<div class="img1"><a href="<?php echo get_field( "image_link_2(7)" ); ?>"><img src="<?php echo $image_27['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_2(8)" ); ?>"><img src="<?php echo $image_28['url']; ?>" /></a></div>
<div class="img1"><a href="<?php echo get_field( "image_link_2(9)" ); ?>"><img src="<?php echo $image_29['url']; ?>" /></a></div>
</div>
<div class="images_txt">
<div class="img_txt"><b><?php echo get_field( "image_heading_2(7)" ); ?> </b></div>
<div class="img_txt1"><b><?php echo get_field( "image_heading_2(8)" ); ?></b> </div>
<div class="img_txt2"><b><?php echo get_field( "image_heading_2(9)" ); ?></b> </div>
</div>
所以在我的情况下,我只添加了 3 个文件作为后端的自定义文件。我已经分配了 9 个,因为将来可能会添加。因为我只有 3 个产品,当它在前端显示时,页面占用空间对于我没有输入的文件。源代码显示每个自定义文件的 div,即使它没有任何显示。所以用户向下滚动一点以到达页脚。你可以看到它HERE。有吗添加未来图像时,该 div 的高度会自动增加。请帮助,谢谢!!
【问题讨论】:
-
您最好将其设置为转发器字段,您是否添加了转发器字段? (advancedcustomfields.com/add-ons/repeater-field)
标签: jquery html css wordpress advanced-custom-fields