You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除WordPress音乐播放器中的引号?求可行解决方案

Remove Quotes from WordPress Audio Player (No Core File Edits Needed)

Hey there! I totally get avoiding edits to core files like media.php—not only is it intimidating, but any changes you make there will get overwritten the next time WordPress updates. Here are some safe, straightforward ways to get rid of those quotes without touching core code:

WordPress has built-in filter hooks that let you modify the audio player’s output on the fly. This is the cleanest approach because it follows WordPress best practices.

Add this code to your theme’s functions.php file (or better yet, a custom plugin—so your changes don’t get lost if you switch themes):

add_filter( 'wp_audio_shortcode', 'remove_audio_player_quotes', 10, 2 );
function remove_audio_player_quotes( $html, $atts ) {
    // Remove all double quotes from the player HTML
    $html = str_replace( '"', '', $html );
    
    // If you only need to target specific quotes (e.g., around certain text), adjust this:
    // $html = str_replace( '"Your Text Here"', 'Your Text Here', $html );
    
    return $html;
}

This function intercepts the HTML generated by the [audio] shortcode and strips out the quotes before it’s rendered on your site.

2. Check for CSS-Generated Quotes

Sometimes quotes are added by your theme’s stylesheet instead of core WordPress code. To verify this:

  1. Right-click the audio player on your site and select "Inspect" (using Chrome, Firefox, or Edge).
  2. Look for pseudo-elements like ::before or ::after attached to the player element—these might be adding quotes via the content property.

If you find them, add this CSS to your theme’s custom CSS section (Go to Appearance > Customize > Additional CSS):

.wp-audio-shortcode::before,
.wp-audio-shortcode::after {
    content: "" !important;
}

This will override any CSS that’s inserting quotes around the player.

3. Create a Custom Audio Shortcode

If you want full control over every part of the audio player’s markup, you can replace the default [audio] shortcode with your own version. This lets you build the HTML exactly how you want it, no quotes included.

Add this code to your functions.php or custom plugin:

function custom_audio_shortcode( $atts ) {
    // Set default attributes for the shortcode
    $atts = shortcode_atts( array(
        'src' => '',
        'loop' => '',
        'autoplay' => '',
        'preload' => 'none',
    ), $atts );

    // Build your custom audio HTML without quotes
    $html = '<audio ';
    $html .= 'src=' . esc_url( $atts['src'] ) . ' ';
    if ( $atts['loop'] ) $html .= 'loop ';
    if ( $atts['autoplay'] ) $html .= 'autoplay ';
    $html .= 'preload=' . $atts['preload'] . '>';
    $html .= '</audio>';

    return $html;
}
// Replace the default audio shortcode with your custom one
add_shortcode( 'audio', 'custom_audio_shortcode' );

Now whenever you use the [audio] shortcode, it will generate your custom quote-free HTML instead of the default version.


内容的提问来源于stack exchange,提问作者dor meljon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:19:38