0

I have a post with audio player with autostart enabled, and i decided to put it in the beginning of the post, before putting "read more" excerpt feature. So the problem is, that audio player plays music on the main page, but i want it to work only on post page. Is it possible to do? I've put my post in drafts for now, until i solve this little problem...

  • By post page do you mean "single post" page? – MartinJJ Jun 20 '11 at 13:49
0

The simplest solution would be to put the audio player after the read-more link.

If that would prove cumbersome (e.g. you've already got too may posts with audio players), you could try hooking into the the_content filter, and remove the audio player if not on a single-post view. e.g.:

function mytheme_remove_audio_player_from_home( $content ) {
    // is_singular() is true for 
    // single posts, pages, and attachments
    if ( ! is_singular() ) {
        // do something, such as a str_replace() or 
        // whatever else would be appropriate, to
        // filter out the audio player markup
    }
    return $content;
}
add_filter( 'the_content', 'mytheme_remove_audio_player_from_home' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.