diff --git a/docs/configuration/wordpress-shortcode.md b/docs/configuration/wordpress-shortcode.md new file mode 100644 index 00000000..445a504c --- /dev/null +++ b/docs/configuration/wordpress-shortcode.md @@ -0,0 +1,171 @@ +# Wordpress shortcode example + +Here is an example Wordpress shortcode file, which can be included in a `functions.php`. + +The shortcode can then be used in a Classic Wordpress page, or Gutenberg shortcode block. This example also has a 'style' parameter for the shortcode, which gets the track data from different Wordpress post types. Each track can have up to three lines in the player. A fairly minimal AmplitudeJS player is used here, but with more data images for each track or album is possible. + +ACF was used to add custom meta data to Audio media, and playlist were added to custom post types with ACF providing more detail about each track. + + +``` + $row ) { + $file_url = $row['url']; + $order[ $i ] = $file_url; + } + + // multisort + array_multisort( $order, SORT_ASC, $songs ); + } + } + + if (count($songs) > 0) { + + $to_return .= << +
+ + +
+ + +
+
+ +
+
+ +
+ + : + +
+ + + +
+ + : + +
+
+
+ + + +
+EOD; + + foreach ($songs as $index => $song) { + $to_return .= " +
+
+
+ \"now +
+
"; + if (array_key_exists('name', $song)) { + $to_return .= "" . $song['name'] . ""; + } else { + $to_return .= " "; + } + if (array_key_exists('artist', $song)) { + $to_return .= "" . $song['artist'] . ""; + }else { + $to_return .= " "; + } + if (array_key_exists('album', $song)) { + $to_return .= "" . $song['album'] . ""; + }else { + $to_return .= " "; + } + $to_return .= " +
+
"; + } + + $to_return .= << + +
+ +
+EOD; + + $to_return .= ''; + } + + return $to_return; +} + +add_shortcode('tcc_audioplayer', 'tcc_audioplayer_func'); + +```