WordPress.org

Ready to get started?Download WordPress

Forums

Simple Fields
to help others with using simplefields (3 posts)

  1. sguk
    Member
    Posted 2 years ago #

    This is how to use simplefields for download links

    <?php $selected_values = simple_fields_get_post_group_values(get_the_id(), "Download link", false,2);
    foreach($selected_values as $value){;
    echo '<div class="downloadtitle">' .( $value[4] ). '</div>';
    echo '<a href="' .wp_get_attachment_url( $value[2] ). '">'.( $value[1] ).'</a>';
    }?>

    what's going on here?
    This is a simplefields repeatable group which consists of a download title such as "download our brochure below", a download title which is the actual link text and a link to the attachment.

    the 3 values are the meta data which simple fields generates.
    value 1 is a text field
    value 2 is a file upload
    value 3 is a text field

    Additionally, separate from simplefields, you can add file icons by using css code similar to this
    a[href$='.doc'], a[href$='.DOC'], a[href$='.docx'], a[href$='.DOCX'] {
    background:transparent url(/images/MIcrosoft-icon.png) center left no-repeat;
    display:inline-block;
    padding-left:25px;
    line-height:18px;
    }

    This will add icons next to your links without the need for javascript.
    I get alot of resources from the internet and I am extremely grateful for those who write and share code. I hope this helps others.

    http://wordpress.org/extend/plugins/simple-fields/

  2. sguk
    Member
    Posted 2 years ago #

    sorry it keeps stripping my code***corrected now***

  3. Pär Thernström
    Member
    Plugin Author

    Posted 2 years ago #

    Great example! Thanks for sharing.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic