0

我有一个页面 ( http://schroeder.s482.sureserver.com/york-family-farm/ ),它是使用高级自定义字段插件从上传的照片生成的照片库。此特定页面中只有一张照片,但其他页面最多可以有 21 张照片。有没有办法让它只显示实际存在的图像?

这是我用来显示它的代码:

    <a href="<?php the_field('featuredimage'); ?>" target="_blank">
    <img src="<?php the_field('featuredimage'); ?>" width="290px" height="217px" id="ffs-pic">
    </a>

非常感谢!喜欢向你们学习!

4

1 回答 1

0

I'm guessing 'featuredimage' is a field you created yourself using the Advanced Custom Fields plugin.

Assuming that's the case, you have a few choices.

  1. Still using the free version, you can create 20 more image fields and name them 'image2', 'image3', 'image4', etc... Then insert them into your template the same way you are displaying 'featuredimage'. This has the obvious downside that you have to manually create everything, rather than looping through your images and generating the HTML programmatically.

  2. Buy one of his add-ons like Gallery or Repeater. They are meant for this sort of thing, and will save you a lot of work.

Let me know if any of that didn't make sense.

于 2013-08-23T18:49:04.727 回答