Hide blog post author name in discord

How to Hide Author Name When Sharing Your Site in Discord













Are you looking to customize the link preview shown in Discord for your WordPress site? Do you also find it annoying that Discord gives more visibility to the author name instead of site title in the link preview? Well, look no further. I have the solution for you. In this article, I will show you how to customize your WordPress site to hide the author name from link previews in Discord.

The Problem with Link Preview in Discord

The information link preview shown in social media sites like Facebook, Twitter are taken from Open Graph tags of the site that is being shared. It is a set of tags in the source of the webpage that shows information like page title, page description, featured image, etc which are used to generate media rich preview of the website in the feed of the social media site.

Discord doesn’t rely on Open Graph tags, instead, it uses something very similar – the oEmbed data to create a rich preview of the shared link. Unfortunately, Discord has a pretty odd looking preview where the author name has more prominence than everything else in the preview. Just take a look at the screenshot of link preview generated in Discord for my website in Discord..

hide author discord link preview

In the first line, you can see the name of my website – “Nigel”, which for some reason has a very tiny font size. In the second line, what you are looking at is author of that page – “Nigel” which for some reason is highlighted in white and is more prominent.

In my opinion, the link preview in Discord lacks a proper structure. I also do not think it is useful to expose author name on link previews, especially for personal blogs. Moreover, I think Discord could take a lesson or two from Twitter and Facebook to create a better looking preview with proper hierarchy for the information that is displayed.

Since Discord relies on oEmbed, it will still show the author name even if the author name is not explicitly exposed anywhere on the webpage or in its source code. This can be concerning for privacy conscious bloggers and website owners.

In my case, I just do not find it nice to have my name repeated twice unnecessarily for the link preview of my personal site.

The Solution to Hide Author Name in Discord Link Preview

While Discord could do something about making their link preview better or hide the author name, it is easier said than done. The best you can do is to make the necessary changes on your site to prevent exposing the author name.

To do this, you will need to add a custom PHP code to modify the oEmbed output generated by your WordPress site. Follow the steps below:

1. Install a Code Snippet plugin to your WordPress site. I recommend WP Code. However, you can find other similar plugins here.

2. Once WP Code plugin is activated, go to Code Snippets > Add Snippet > create your own.

wordpress hide author discord

3. Give a title for the snippet and select “PHP Snippet” for the Code Type.

4. Paste the following code:

add_filter( 'oembed_response_data', 'hide_author_filter_oembed_response_data_' );
function hide_author_filter_oembed_response_data_( $data ) {
    return $data;

5. Set Location to Location to “Frontend Only”.

6. Save the snippet and Activate it.

Here’s a screenshot from my blog after I added the code:

discord link preview hide author name

Please note, you may need to add some URL parameter at the end like “?x=123” for recently shared URLs to prevent Discord showing link preview from its cache. In the above screenshot, I had to use the URL “?x=123” to skip its cache.

That should be it! Next time when you share a new page from your website, Discord will no longer show the author name.

If you found this guide useful, do let me know in the comment below. Stay tuned for more tips and guides!

One response to “How to Hide Author Name When Sharing Your Site in Discord”

  1. You saved my a** with this post. Thanks!!

Leave a Reply

Your email address will not be published. Required fields are marked *