forked from RadoslavGeorgiev/ultimate-fields
-
Notifications
You must be signed in to change notification settings - Fork 0
Audio
JIX edited this page Jul 14, 2020
·
1 revision
The Audio field builds on top of the File Field and allows users to select multiple audio files for a single player.
When files have been selected, the field uses them as <src />
sub-tags for an audio tag. In the back-end, once files have been selected, an audio player preview is shown.
There are no additional settings for the audio field.
Using get_value
to get the value of an audio field returns a boolean false
when no files have been selected or an array with file IDs.
Using the_value
will generate an HTML5 <audio>
tag with all selected files as sources. This does not enqueue and scripts and styles automatically for the front-end.
<!-- Complete player -->
<?php the_value( 'song' ) ?>
<!-- Manual generation --?
<?php if( $files = get_value( 'song' ) ): ?>
<audio controls>
<?php foreach( $files as $file ): ?>
<source src="<?php echo wp_get_attachment_url( $file ) ?>" type="<?php echo get_post_mime_type( $file ) ?>" />
<?php endforeach ?>
</audio>
<?php endif ?>
Quick start
- Creating fields and using their values
- Installation
- Administration interface
- Using the PHP API
- Container Settings
Locations
- Overview & Usage
- Post Type
- Options Page
- Taxonomy
- Comment
- User
- Widget
- Shortcode
- Menu Item
- Attachment
- Customizer
Fields
- Fields
- Text
- Textarea
- WYSIWYG
- Password
- Checkbox
- Select
- Multiselect
- Image Select
- File
- Image
- Audio
- Video
- Gallery
- WP Object
- WP Objects
- Link
- Date
- DateTime
- Time
- Color
- Font
- Icon
- Map
- Embed
- Number
- Sidebar
- Complex
- Repeater
- Layout
- Section
- Tab
- Message
Features
- Adding fields to the Customizer
- Conditional Logic
- Front-End Forms
- Administration columns
- Import and Export
- REST API
- JSON Synchronization
- Yoast SEO
Ultimate Post Types
Functions and API
Tutorials