WordPress.org

Ready to get started?Download WordPress

Forums

Custom Field Template
[resolved] Add text box if previous is not null (4 posts)

  1. seanjacob
    Member
    Posted 2 years ago #

    So I currently have a 4 banner slideshow that gets populated from my four separate fields that include the url of the images. I would like to be able to add more banners without having to create another separate set field.

    I hope that makes sense, thank you.

    http://wordpress.org/extend/plugins/custom-field-template/

  2. Edd Hurst
    Member
    Posted 2 years ago #

    The easiest way for you to do this is to use the Multiple argument. This will automatically add an extra field to your set, so you will always be able to add more fields to your slideshow.

    This is also a lot neater codewise.

    example:

    [Main Image]
    type = file
    label = Upload Main Image ( 940px by 280px )
    mediaLibrary = true
    multiple = true
    multipleButton = true

    "Multiple" will allow you to add more fields so that when you upload 4 and save - it will automatically show your 4 fields and 1 empty one when you next load the page.

    "MultipleButton" will allow you to manually add more fields, if you wanted to add more than one at a time.

  3. Edd Hurst
    Member
    Posted 2 years ago #

    for what it's worth - you would retrieve those much the same as you would a normal custom field.

    <?php
    $slideshow_images = get_post_custom_values('Main Image', $post->ID);
    foreach ( $slideshow_images as $key => $value ) {
    	echo "<div class=\"slideshow-img\">";
    	echo $value;
    	echo "</div>";
    }
    ?>

    I can't remember how cft outputs a file, but in theory that would work...

  4. seanjacob
    Member
    Posted 2 years ago #

    Thank you Edd! The is exactly what I was looking for, there should be a detailed list for what every type does.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic