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

  1. sguk
    Posted 5 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;

    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.


  2. sguk
    Posted 5 years ago #

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

  3. Pär Thernström
    Plugin Author

    Posted 5 years ago #

    Great example! Thanks for sharing.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic