Featured Audio

WordPress supports featured images out of the box, allowing images to represent posts in various ways defined by the theme. This plugin adds similar support for audio, allowing musicians, podcasters, and anyone who publishes audio with WordPress to feature audio files on posts and pages in a structured way. Each post and page gets a featured audio metabox where an audio file can be uploaded or selected from the media library.

By default, featured audio is displayed at the top of posts and pages (within the_content). Developers can change this by adding theme support for featured-audio, via several API functions listed below.

Why use featured audio instead of embeding audio directly into posts? Featured audio organizes the content in a structured way, alowing infinite possibilities to customize the way users experience audio content on your site. The plugin ships with one example of this – the featured audio playlist widget. Add this widget to your sidebar and it’ll automatically display a playlist of all of the audio files featured on posts shown on the current view, on views with more than one post such as the main blog page or a category page. The plugin also supports a recent audio playlist widget, which behaves similarly to a latest posts widget.

For a more comprehensive way to manage music with WordPress, particularly if you need to include sheet music alongisde audio, see the Sheet Music Library plugin.

Developer API Functions

Add Theme Support

Adding theme support for featured audio tells the plugin not to add the featured audio to the content automatically. Instead, you can add featured audio exactly where you want it with the_featured_content() (see below for details).

Change Supported Post Types

By default, the post and page post types are supported. You can use the featured_audio_post_types filter to modify this list. For example:

the_featured_audio( $args )

Display the featured audio, if it exists.

Parameters:

get_the_featured_audio( $args )

Get the featured audio, if it exists, as a string. Has the same arguments as the_featured_audio().

get_featured_audio_src( $id )

Returns the url of the featured audio file, if it exists.

Parameter:

get_featured_audio_attachment_id( $id )

Returns the id of the featured audio attachment, if it exists.

Parameter:

get_the_featured_audio_playlist()

Get the featured audio playlist, if there are multiple posts with featured audio in the current query. Used by the featured audio playlist widget.

the_featured_audio_playlist()

Displays (echoes) get_the_featured_audio_playlist().

0

评论0

 
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
显示验证码
没有账号?注册  忘记密码?

社交账号快速登录