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

WordPress站点链接在Discord展示异常,作者信息前置求助

Hey! I’ve dealt with this exact Discord link preview issue on WordPress sites before—super annoying when that author info cuts in front of your intended description, especially if you share links often. Let’s figure out why this is happening and how to fix it:

Why This Happens

Discord uses the Open Graph (OG) protocol to generate link previews, but its parsing logic has a quirk: if your WordPress site outputs an og:author tag (or even a standard author meta tag) alongside your og:description, Discord will sometimes slot that author info between the domain and your custom description. That’s why you’re seeing the [mydomain.com] admin [描述] format. Other platforms tend to de-prioritize or ignore the author tag in previews, which is why they display correctly.

Fixes to Try

1. Use an SEO Plugin (Easiest Solution)

Popular WordPress SEO plugins like Yoast SEO or Rank Math let you fully control Open Graph metadata, which is the fastest way to fix this. Here’s how to do it with Yoast:

  • Edit the post/page you want to share (or adjust global settings if you want this fix site-wide).
  • Scroll down to the Yoast SEO panel, click the Social tab.
  • Under the Facebook section (Discord follows Facebook’s OG standards), enter your desired preview description in the Description field.
  • Optional: If your plugin auto-adds an og:author tag, look for a setting to disable it (usually in the plugin’s "Social" or "Advanced" settings). This stops Discord from picking up that author data entirely.
  • Save your changes, then test the link in a private Discord channel to confirm the preview looks right.

2. Manually Override OG Tags (For Advanced Users)

If you prefer not to use a plugin, you can add custom code to your theme’s functions.php file (always use a child theme to avoid losing changes when your theme updates) to force the correct OG tags and suppress the author info:

function custom_discord_og_preview() {
    if (is_singular()) { // Target single posts/pages
        global $post;
        
        // Grab your custom description (use Yoast's meta if available, else generate from content)
        $custom_desc = get_post_meta($post->ID, '_yoast_wpseo_metadesc', true);
        if (!$custom_desc) {
            $custom_desc = wp_trim_words(strip_tags(get_the_content()), 155);
        }
        
        // Output core OG tags (override any default ones)
        echo '<meta property="og:title" content="' . esc_attr(get_the_title()) . '" />';
        echo '<meta property="og:description" content="' . esc_attr($custom_desc) . '" />';
        echo '<meta property="og:url" content="' . esc_attr(get_permalink()) . '" />';
        
        // Prevent Yoast from adding author OG tags (adjust if using a different plugin/theme)
        remove_action('wp_head', 'wpseo_opengraph_author');
    }
}
add_action('wp_head', 'custom_discord_og_preview', 5); // High priority to load first

After adding this code, clear your WordPress cache (if you use a caching plugin) and test the link in Discord again.

3. Test and Refresh Previews

Discord caches link previews, so if you’ve made changes, append a query string to the URL (e.g., ?test=1) to force a fresh preview. Always test in a private channel first before sharing publicly to avoid any awkward displays.

内容的提问来源于stack exchange,提问作者Maciek Tracz

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 09:04:32