WordPress.org

Ready to get started?Download WordPress

Forums

Simple Fields
[resolved] Displaying collated content of field group (3 posts)

  1. mahlerthetitan
    Member
    Posted 10 months ago #

    Hello!
    I love, love, love this plugin.
    But I'm running into a problem.

    I have one field group (with slug 'audiounique') that contains three fields:

    FIELD 1
    Name: Audio File
    Slug: audiofile
    Type: File

    FIELD 2
    Name: Sound Clip Info
    Slug: audioinfo
    Type: Textarea (Small height; HTML editor)

    FIELD 3
    Name: Audio Composer
    Slug: audiocomposer
    Type: Textarea (Default height)

    I'd like to have a post which displays

    audioinfo1
    audiofile1
    audiocomposer1

    audioinfo2
    audiofile2
    audiocomposer2

    etc.

    I have tried to figure out the php magic to accomplish this, but haven't had luck.

    For example, I tried the following:

    <?php

    $audioinfo = simple_fields_values("audioinfo");
    $audiofile = simple_fields_values("audiofile");
    $audiocomposer = simple_fields_values("audiocomposer");

    for($i=0;$i<count($audioinfo);$i++)
    {
    echo $audioinfo[$i];
    echo $audiofile[$i];
    echo $audiocomposer[$i];
    }
    ?>

    However, using this code, the audiocomposers values are rendered above all other values, like this:
    ArrayBachArrayBeethovenArrayMozart
    Thanks for your help!

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

  2. mahlerthetitan
    Member
    Posted 10 months ago #

    Okay, I can see now that the formatting is not a problem. It's because one field is HTML and one isn't. I can fix that later.

    What's most important is that $audiofile is retuning an array.
    I know this is because the field is returning an extended array of info.

    So I need to change
    echo $audiofile[$i];
    to something like:
    echo $audiofile['url'][$i];

    But this doesn't work.
    How can I call on each $i iteration of the URL part of the 'audiofile' array?

    Thanks!
    Chris

    How can I return the URL for each of the "audiofile" fields?

    Thanks.

  3. mahlerthetitan
    Member
    Posted 10 months ago #

    ...I just had to flip the two bracketed items.

    From
    echo $audiofile['url'][$i]
    to
    echo $audiofile[$i]['url']

    Huzzah!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.