Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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...

share|improve this question
    
By post page do you mean "single post" page? –  MartinJJ Jun 20 '11 at 13:49
add comment

1 Answer

up vote 0 down vote accepted

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' );
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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