Updated 2026-11-23

WordPress SEO without a plugin: what core prints and what it leaves out

We checked 771 pages on 69 WordPress sites. Only 1% had no canonical link and 1% no lang, because WordPress prints those itself. But 37% had no meta description at all, and 23% had no Open Graph tags or no og:image, so a shared link shows no picture. 27% had no JSON-LD. WordPress core doesn't write any of those three. This guide shows exactly what core prints, adds the missing tags with one small file, and cleans up the sitemap.

Tested on WordPress 7.1.3 with the default Twenty Twenty-Five theme and no plugins, in a fresh install.

1. What WordPress prints with no SEO plugin

2. Add descriptions, Open Graph and JSON-LD

If you already run Yoast SEO, Rank Math, All in One SEO, SEOPress or The SEO Framework, you don't need this; it steps aside when one of them is active. Otherwise save the file below as wp-content/mu-plugins/seo-basics.php (create the folder if needed). Must-use plugins load automatically and survive theme switches, unlike code in a theme's functions.php.

<?php
/**
 * Plugin Name: SEO basics
 * Description: Meta description, Open Graph, X card and JSON-LD for sites without an SEO plugin.
 */

// Author archives leak login names and are rarely worth indexing.
add_filter( 'wp_sitemaps_add_provider', function ( $provider, $name ) {
	return 'users' === $name ? false : $provider;
}, 10, 2 );

add_action( 'wp_head', function () {
	// Yoast, Rank Math, AIOSEO, SEOPress and The SEO Framework print these tags themselves.
	if ( defined( 'WPSEO_VERSION' ) || defined( 'RANK_MATH_VERSION' ) || defined( 'AIOSEO_VERSION' )
		|| defined( 'SEOPRESS_VERSION' ) || defined( 'THE_SEO_FRAMEWORK_VERSION' ) ) {
		return;
	}
	$site  = get_bloginfo( 'name' );
	// Both come back HTML-escaped (&#8211;, &#038;); decode once so JSON-LD gets plain text.
	$title = html_entity_decode( is_singular() ? single_post_title( '', false ) : wp_get_document_title(), ENT_QUOTES, 'UTF-8' );
	$url   = is_singular() ? get_permalink() : ( is_front_page() ? home_url( '/' ) : '' );
	$desc  = '';
	$image = '';
	if ( is_singular() ) {
		$post = get_queried_object();
		$desc = has_excerpt( $post ) ? $post->post_excerpt : $post->post_content;
		if ( has_post_thumbnail( $post ) ) {
			$image = get_the_post_thumbnail_url( $post, 'large' );
		}
	} elseif ( is_front_page() ) {
		$desc = get_bloginfo( 'description' );
	} elseif ( is_category() || is_tag() || is_tax() ) {
		$desc = term_description();
	}
	$desc = wp_trim_words( wp_strip_all_tags( strip_shortcodes( $desc ), true ), 28, '…' );
	if ( ! $image && has_site_icon() ) {
		$image = get_site_icon_url( 512 );
	}

	if ( is_front_page() && ! is_singular() ) {
		printf( '<link rel="canonical" href="%s" />' . "\n", esc_url( $url ) );
	}
	if ( $desc ) {
		printf( '<meta name="description" content="%s" />' . "\n", esc_attr( $desc ) );
		printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( $desc ) );
	}
	printf( '<meta property="og:title" content="%s" />' . "\n", esc_attr( $title ) );
	printf( '<meta property="og:site_name" content="%s" />' . "\n", esc_attr( $site ) );
	printf( '<meta property="og:type" content="%s" />' . "\n", is_single() ? 'article' : 'website' );
	if ( $url ) {
		printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( $url ) );
	}
	if ( $image ) {
		printf( '<meta property="og:image" content="%s" />' . "\n", esc_url( $image ) );
	}
	printf( '<meta name="twitter:card" content="%s" />' . "\n", $image ? 'summary_large_image' : 'summary' );

	$ld = is_single()
		? array(
			'@context'      => 'https://schema.org',
			'@type'         => 'BlogPosting',
			'headline'      => $title,
			'datePublished' => get_the_date( 'c' ),
			'dateModified'  => get_the_modified_date( 'c' ),
			'url'           => $url,
		)
		: ( is_front_page() ? array(
			'@context' => 'https://schema.org',
			'@type'    => 'Organization',
			'name'     => $site,
			'url'      => home_url( '/' ),
		) : null );
	if ( $ld ) {
		if ( $image ) {
			$ld[ is_single() ? 'image' : 'logo' ] = $image;
		}
		// wp_json_encode escapes "/" so a title can't close the script tag.
		echo '<script type="application/ld+json">' . wp_json_encode( $ld ) . "</script>\n";
	}
}, 1 );

3. Clean up the sitemap

4. Check the result

curl -s https://example.com/ | grep -E -o '<(link rel="canonical"|meta (name|property)="(description|og:[a-z_]+|twitter:card)")[^>]*>'
curl -s https://example.com/wp-sitemap.xml | grep -o '<loc>[^<]*'
wp post list --post_type=post,page --fields=ID,post_title,post_excerpt --post_status=publish

The first shows the head tags of one page, the second the sitemap's sub-sitemaps (no users one after the clean-up), the third which posts still have no excerpt. A page cache serves the old HTML until it is cleared, so purge it after adding the file. To see a page the way Google and link previewers do, run it through the free SEO checker, or up to 50 pages from your sitemap through the site checker.

Automating it with Headlark

The snippet's descriptions are the first words of each page, which is better than nothing but rarely a good summary, and writing excerpts for hundreds of posts is the slow part. The Headlark plugin writes each post's title, description, Open Graph and X cards, JSON-LD and missing alt text from the post's own content when you publish or update it, and stores the result with the post, so nothing runs when a visitor loads the page.

Try it

Try it free for 14 days on one site and up to 500 pages, no card needed. Add your site, install the plugin and paste the site's key in Settings → Headlark.