Show audio player only in specific post type

This is untested, but it seems to me that you could simply replace the: $audio = “<audio src=”https://wordpress.stackexchange.com/questions/382777/$url” controls autoplay loop></audio>”; with $autoplay = is_singular( ‘your_post_type’ ) ? ‘autoplay’ : ”; $audio = “<audio src=”https://wordpress.stackexchange.com/questions/382777/$url” controls $autoplay loop></audio>”; I.e. We use the $autoplay variable to store the autoplay attribute, and if the current page is … Read more

Show audio player only in specific post type category

Have you tried has_category? You can add a check to make sure the post has the specified category. If not then return the content un changed like below: <?php add_filter( ‘woocommerce_short_description’, ‘wpse_67108_autplay_music’ ); function wpse_67108_autplay_music( $content ) { if ( ! is_singular( ‘product’ ) && ! has_category( ‘<your specific category here>’ )) { return $content; … Read more

Make Audio Element Persistent Across Pages

Maybe the “normal” wordpress themes are not the right tool here, and what you need is a “headless” wordpress with {insert JS framework} to get the content via the json API and handle the page routing without performing actuall page refresh. Another possible solution is to turn it from audio to video as browsers now … Read more

Error Using Audio plugin

Answered my own question. Kept here for others who may have in the same problem. Turns out, being locally hosted WAS relevant. the problem is line 192 in /wp-content/plugins/audio/js/audio.js swfPath: ‘http://’ + window.location.host + ‘/wp-content/plugins/audio/js/’, This expects the site to be based at the root /, as mine was in a folder I just changed … Read more

Display Audio Attachment URL

Assuming you do know the attachment $id, you can use wp_get_attachment_url(): <?php wp_get_attachment_url( $id ); ?> If you need to determine the attachment $id, you can use get_posts(): global $post; $audio_attachments = get_posts( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘audio’ ) ); If you have multiple (or unknown number of) audio attachments, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)