我有一篇文章中的音频播放器启用了autostart,我决定将其放在文章的开头,然后再放上“阅读更多”摘录功能。所以问题是,音频播放器在主页上播放音乐,但我希望它只在贴子页上工作。有可能吗?我现在已经把我的帖子放到草稿里了,直到我解决了这个小问题。。。
如何禁用“音频播放器”显示在主页
1 个回复
最合适的回答,由SO网友:Chip Bennett 整理而成
最简单的解决方案是将音频播放器放在“阅读更多”链接之后。
如果这会证明很麻烦(例如,你已经收到了太多带有音频播放器的五月帖子),你可以尝试连接到the_content
过滤,如果不在单个后期视图上,请卸下音频播放器。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\' );
结束