Security PHP Beginner

Hide Author Details From oEmbed Responses

Remove the author name and author archive URL WordPress includes when other sites embed your posts.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 4 lines
add_filter( 'oembed_response_data', function ( array $data ): array {
	unset( $data['author_name'], $data['author_url'] );
	return $data;
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

When someone embeds your post on another site, WordPress answers a public oEmbed request with the post’s title, an excerpt and the author’s name and archive URL. The URL often contains the author’s username. This snippet removes the author fields.

How it works

The oembed_response_data filter receives the data WordPress returns from /wp-json/oembed/1.0/embed. Removing author_name and author_url leaves the title, thumbnail and HTML, so embeds still work.

Things to watch

  • Combine with the user enumeration snippet and “Disable Author Archives” to close the other places usernames appear.

How to test it

Open yoursite.com/wp-json/oembed/1.0/embed?url= followed by one of your post URLs. The JSON should have no author_name or author_url.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only