A content audit dashboard fails in a specific, boring way: it reports zero problems because it looked in the wrong place. Alt text, meta descriptions, and internal links live in three different stores. A dashboard that assumes one store will silently miss the other two, and the report will look clean while the site is not.
This is a data-location problem before it is a UI problem. The three checks read:
- Alt text — attachment post meta, key
_wp_attachment_image_alt. - Meta descriptions — a post meta key written by whatever SEO layer the site runs. Core has none.
- Internal links — the stored
post_content. Core maintains no link table.
The design rule that follows: name the store each check reads, check key existence separately from value emptiness, and state the dashboard’s coverage. A dashboard that does not say what it scanned cannot be trusted when it says zero.
Symptom: the dashboard says everything is fine
The common failure is a dashboard that queries get_post_meta( $id, 'meta_description', true ), gets an empty string back for every post, and concludes the site is compliant. Or one that reads alt text from the rendered img tag and misses the media library field entirely. Or one that counts internal links by scanning for href and includes every external URL on the page.
Each of these produces a false clean. The fix is not a better UI. It is a query that reads the right store and reports its own scope.
Trace: where each check actually reads
Alt text is attachment meta, not content markup
WordPress stores the media library alt field as post meta on the attachment, under the key _wp_attachment_image_alt. The REST attachments controller reads it exactly that way when it builds the alt_text field:
if ( in_array( 'alt_text', $fields, true ) ) {
$data['alt_text'] = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
}
That is from the WP_REST_Attachments_Controller::prepare_item_for_response() source. The implication for the dashboard: the check is a query against wp_postmeta joined to attachments, not a parse of post content.
The gap to state up front: this field is the media library’s alt value. It is not the same as an alt attribute typed directly into block markup. If an editor inserted an image and wrote alt text in the block inspector, that value may live in the block attributes inside post_content rather than in the attachment meta. The dashboard should say which one it checks.
Meta descriptions have no core home
Core WordPress does not ship a meta description field. The REST posts schema exposes a meta object, but that object contains only fields that have been registered — it is not a container of SEO data by default. As one practitioner guide puts it, without Yoast SEO or RankMath the REST response has only core fields such as the rendered title and raw content, not meta descriptions or robots directives (RapidDev, “How to Automate WordPress SEO Reports using the API”).
So the dashboard must read whatever key the site’s SEO layer writes. That key is plugin- and version-dependent. The same guide notes that Yoast exposes a yoast_head_json object in REST responses, but also that the exact meta key names used for updates vary by version. Do not hardcode a key from a blog post. Confirm it against the site’s own database before building the check.
Here is the failure mode that matters. get_post_meta() with $single = true returns an empty string when the key is absent. The function reference documents the $single parameter and notes it has no effect if $key is not specified. The practical consequence: “missing” and “present but empty” look identical through that call. A dashboard that treats the empty string as proof of absence will report a site as clean when the key is simply named differently.
The fix is to check key existence separately from value emptiness. get_post_custom_keys() returns the keys that exist for a post, so the dashboard can distinguish “no such key” from “key exists, value empty.”
Internal links are a content parse, not a table lookup
Core does not maintain a table of links between posts. The only reliable source is the stored post_content. The check is a parse of that column for links whose host matches the site’s own host, with a stated rule for what counts.
The blind spots are real and should be printed on the dashboard, not buried in a footnote:
- Links rendered by blocks at output time, shortcodes, or templates will not appear in
post_content. - Links added by the block editor’s navigation or query blocks may be stored as block attributes rather than as
hrefvalues in the content string. - Relative URLs and protocol-relative URLs need an explicit rule.
A dashboard that claims to count internal links without naming these limits is overstating its coverage.
Root cause: per-post loops and wrong-store assumptions
Two design mistakes produce most of the false results.
Mistake one: a per-post get_post_meta loop. For a site with a few hundred posts, looping over every post and calling get_post_meta turns one query into N queries and hides the key-existence question inside a falsy return value. The wpdb documentation describes get_col() as returning a one-dimensional array and an empty array when no result is found — which is exactly the shape needed for a set-based “which posts lack this key” pass.
Mistake two: assuming the REST posts endpoint returns SEO meta. It does not, unless a plugin registers those fields. The posts schema lists meta as an object, but the object is populated only by registered meta. A dashboard that reads meta.meta_description from /wp/v2/posts without confirming registration will get nothing and report clean.
Fix: three set-based queries and one content scan
The dashboard should be read-only. It reports state; it does not write corrections. Mixing audit and repair invites save_post recursion and makes the report’s state ambiguous. The save_post reference documents the infinite-loop hazard when a callback calls wp_update_post without unhooking first. Keep the audit pass out of that path entirely.
Check 1: attachments missing alt text
This is a set-based query against wp_postmeta. Use $wpdb->prepare() for the key value. The wpdb documentation states that all untrusted values in an SQL statement must be escaped and that prepare() performs this for WordPress.
global $wpdb;
$missing_alt = $wpdb->get_col(
$wpdb->prepare(
"SELECT p.ID
FROM {$wpdb->posts} p
LEFT JOIN {$wpdb->postmeta} pm
ON pm.post_id = p.ID
AND pm.meta_key = %s
WHERE p.post_type = 'attachment'
AND p.post_mime_type LIKE %s
AND ( pm.meta_value IS NULL OR pm.meta_value = '' )",
'_wp_attachment_image_alt',
'image/%%'
)
);
Note the double-% in the LIKE pattern. The wpdb documentation is explicit: all % characters inside SQL string literals, including LIKE wildcards, must be double-% escaped as %%. Getting this wrong produces a prepare error, not a wrong result — which is at least a loud failure.
This query returns attachments where the meta row is absent or the value is empty. It does not distinguish the two. If the dashboard needs that distinction, run a second query that selects only rows where the meta key exists and the value is empty, and subtract.
Check 2: posts missing the SEO meta description key
First, confirm the key. Run this against the site’s database or via WP-CLI:
wp db query "SELECT meta_key, COUNT(*) AS n
FROM wp_postmeta
WHERE meta_key LIKE '%desc%'
GROUP BY meta_key
ORDER BY n DESC;"
That surfaces the actual key names in use. Do not assume _yoast_wpseo_metadesc or any other name from a tutorial. The RapidDev guide cited above notes that the exact key names vary by plugin version.
Once the key is confirmed, the missing-key query is a LEFT JOIN that selects posts where the meta row is absent:
global $wpdb;
$seo_key = '_yoast_wpseo_metadesc'; // confirm against the site first
$missing_desc = $wpdb->get_col(
$wpdb->prepare(
"SELECT p.ID
FROM {$wpdb->posts} p
LEFT JOIN {$wpdb->postmeta} pm
ON pm.post_id = p.ID
AND pm.meta_key = %s
WHERE p.post_type = 'post'
AND p.post_status = 'publish'
AND pm.meta_id IS NULL",
$seo_key
)
);
This returns posts where the key does not exist at all. A separate query returns posts where the key exists but the value is empty:
$empty_desc = $wpdb->get_col(
$wpdb->prepare(
"SELECT p.ID
FROM {$wpdb->posts} p
INNER JOIN {$wpdb->postmeta} pm
ON pm.post_id = p.ID
AND pm.meta_key = %s
WHERE p.post_type = 'post'
AND p.post_status = 'publish'
AND pm.meta_value = ''",
$seo_key
)
);
Two queries, two lists. The dashboard can now report “key absent” and “key present, value empty” as distinct states. That distinction is the difference between a dashboard that finds the wrong-key problem and one that hides it.
Check 3: internal links in post content
There is no link table. The check is a parse of post_content. Use WP_Query or get_posts here because the scan needs full post objects, not just IDs. The set-based SQL shape is wrong for this pass.
$site_host = wp_parse_url( home_url(), PHP_URL_HOST );
$posts = get_posts( array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
) );
$no_internal = array();
foreach ( $posts as $post_id ) {
$content = get_post_field( 'post_content', $post_id );
$has_internal = false;
if ( preg_match_all( '/]*href=["\']([^"\']+)["\']/i', $content, $matches ) ) {
foreach ( $matches[1] as $href ) {
$host = wp_parse_url( $href, PHP_URL_HOST );
if ( $host === null || $host === $site_host ) {
$has_internal = true;
break;
}
}
}
if ( ! $has_internal ) {
$no_internal[] = $post_id;
}
}
This is a regex over stored content, not a DOM parse. It will miss links rendered by blocks at output time and links stored as block attributes rather than as href strings. The dashboard should print that limitation next to the result.
For a more accurate parse, run the content through do_blocks() and then parse the rendered HTML. That catches links that blocks render. It does not catch links added by templates or shortcodes that run later in the render pipeline. State the boundary.
Verification: make the dashboard report its own coverage
A dashboard that says “zero missing” is only useful if it also says what it scanned. The output should include:
- Number of published posts scanned.
- Number of image attachments scanned.
- The exact meta key checked for meta descriptions.
- Whether the internal-link check parsed raw content or rendered blocks.
- The site host used to classify links as internal.
Without those five facts, a zero is not a result. It is a guess.
To verify the queries themselves, run them against a known-bad post. Create a draft with no meta description, confirm it appears in the missing-key list, then add the key and confirm it moves to the empty-value list or drops out. If the dashboard cannot distinguish those states, the key-existence check is not working.
What the dashboard cannot tell you
State these limits in the dashboard itself, not in a README nobody reads:
- Alt text in block markup. The
_wp_attachment_image_altcheck reads the media library field. Alt text typed into a block’s image settings may live in block attributes insidepost_contentand will not appear in this check. - Links generated at render time. Shortcodes, template parts, and blocks that build links dynamically will not appear in a
post_contentparse. - SEO fields from plugins that do not expose a queryable meta key. If the SEO layer stores descriptions somewhere other than
wp_postmeta, the meta-key check will report every post as missing. Confirm the storage location before trusting the result. - REST-only SEO data. Some plugins expose SEO fields in REST responses without writing a queryable meta key. The dashboard reads the database, not the REST output, so those fields are invisible to it.
The shape of a trustworthy audit
Three checks, three stores, one rule: name the store, check key existence separately from value emptiness, and print the coverage. The dashboard is a read-only diagnostic over WordPress’s own data model. It does not wrap a plugin’s REST output, and it does not write corrections.
The failure mode to design around is the false clean. A dashboard that queries the wrong meta key, or that treats an empty string as proof of absence, will report a site as compliant when it is not. The fix is not a better UI. It is a query that reads the right place and says so.
If the site is new enough that the dashboard returns nothing at all, start with the basics before building audit queries — see What to Fix First When a New WordPress Site Says Nothing Found.
FAQ
Why does get_post_meta return an empty string for a key I know exists?
It may not exist. With $single = true, a missing key returns an empty string, and a key that exists with an empty value also returns an empty string. Use get_post_custom_keys() to check existence separately from value.
Can I read meta descriptions from the REST posts endpoint?
Only if a plugin registers the field. The posts schema lists meta as an object, but it contains only registered meta. Without an SEO plugin that registers the field, the response has no meta description. Confirm registration before relying on it.
Why does my internal-link count include external links?
The parse is matching every href without comparing the host. Compare wp_parse_url( $href, PHP_URL_HOST ) against wp_parse_url( home_url(), PHP_URL_HOST ) and treat relative URLs as internal by rule.
Should the dashboard fix the issues it finds?
No. Keep the audit pass read-only. Writing corrections from the audit invites save_post recursion and makes the report’s state ambiguous. Let editors fix issues in the editor.
How do I know the dashboard is checking the right meta key?
Query the database for keys matching the pattern before building the check. wp db query "SELECT meta_key, COUNT(*) FROM wp_postmeta WHERE meta_key LIKE '%desc%' GROUP BY meta_key;" surfaces the actual key names in use. Do not assume a key name from a tutorial.