I'm currently using the advanced custom fields plugin on a wordpress site that I'm developing and it is proving very useful.
I bought the repeater addon which had helped me generate a list of staff members. However I imagine that there won't always be an image available for the staff member so I would like to use a fallback image or use an online placeholder image service like http://placehold.it?
Here is the code:
<?php if(get_field('about_the_practioner')): ?> <?php while(the_repeater_field('about_the_practioner')): ?> <article class="colleague_excerpts"> <figure> <img src="<?php the_sub_field('image'); ?>" alt="<?php the_sub_field('image_alt_text'); ?>"> </figure> <div class="description"> <header> <h4><?php the_sub_field('header')?><span><?php the_sub_field('title')?></span></h4> </header> <p><?php the_sub_field('text') ?></p> <a href="<?php the_sub_field('page_link')?>" class="button"><?php the_sub_field('page_link_text') ?></a> </div> <hr> </article> <?php endwhile; ?> <?php endif; ?>
I've seen conditional statements used to create fallback images if a featured image is not available. I'm guessing something similar would be appropriate in this case at the point where the image is called although I'm unsure of the syntax as I'm not good with php. Any help would be appreciated.