Displaying multiple files with line break instead of comma

Support General Displaying multiple files with line break instead of commaResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #47535
    HardlyWorkingHardlyWorking
    Participant

    Hello, I created a simple metabox File Advanced field where a user can upload multiple files. However, I would like this to display as a list of items rather than "file1, file 2, file3,..."

    Is there a simple way to accomplish this?

    Thank you.

    #47543
    PeterPeter
    Moderator

    Hello,

    You can follow the documentation below to use the code to output the field value
    https://docs.metabox.io/fields/file-advanced/#template-usage

    then you can output the items in any list as you want. Here is an example

    
    <?php $files = rwmb_meta( 'my_field_id' ); ?>
    <h3>Uploaded files</h3>
    <ul>
        <?php foreach ( $files as $file ) : ?>
            <li><a href="<?= $file['url']; ?>"><?= $file['name']; ?></a></li>
        <?php endforeach ?>
    </ul>
    
    #47553
    HardlyWorkingHardlyWorking
    Participant

    Many thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.