Skip to content

Read the post from Yoast's context when adding citations - #252

Merged
dknauss merged 4 commits into
mainfrom
claude/project-thread-6zozsp-yoast-context
Nov 6, 2026
Merged

dknauss merged 4 commits into
mainfrom
claude/project-thread-6zozsp-yoast-context

Conversation

@dknauss

@dknauss dknauss commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Requested by Dan · project thread

Summary

  • What changed? Borges's wpseo_schema_article and wpseo_schema_webpage filters now take the post from the Meta Tags Context that Yoast passes with each piece, and fall back to the queried post only when the context has no post. bibliography_builder_json_ld_page_url() takes an optional post, and passes it to the bibliography_builder_json_ld_page_url filter as a second argument.
  • Why was this change needed? Borges found the post through the main query (is_singular() / get_queried_object()), so a graph Yoast built for some other caller came back without the citation edge. NLWeb's WordPress plugin is one such caller. It calls YoastSEO()->meta->for_post() to answer agents over MCP. On a local WordPress 7.1 + Yoast SEO 28.8 + NLWeb site, its ask answer for the fixture post had 0 citations before this change and 12 after. The page's own JSON-LD and Yoast's schema aggregator (/wp-json/yoast/v1/schema-aggregator/…) already had all 12, because both set up the global query state.

I found this while tracing citation metadata through Yoast and NLWeb (the study PR follows separately). I didn't touch the Rank Math path. Its rank_math/json_ld filter has the same reliance on the main query, but I haven't tested it with a Rank Math caller outside the page request.

Validation

  • composer test:php passes: 714 tests. The new test_yoast_pieces_read_the_post_from_yoast_context fails on main and passes here.
  • phpcs is clean on the changed files
  • Psalm not run locally: it needs PHP ≥ 8.3.16 and the container has 8.3.6, so CI will run it
  • Checked live: an NLWeb MCP tools/call ask against a local site now returns the Article with its citation list
  • JS is unchanged, so the JS lint, test and build items don't apply

Checklist


Generated by Claude Code

Borges added the cited works to Yoast SEO's Article (or WebPage) piece
using the main query's post, so a graph Yoast built for another caller
had no citations. NLWeb's WordPress plugin is one: it calls
YoastSEO()->meta->for_post() to answer agents over MCP, and its answers
lost the citation edge. Found while tracing citation metadata through
Yoast and NLWeb on a local site.

The Yoast filters now take the post from the context Yoast passes, and
bibliography_builder_json_ld_page_url() accepts that post, passing it
to its filter as a second argument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA2F1J2N3yCPk3cUX1P
@dknauss dknauss self-assigned this Nov 4, 2026
get_permalink() takes a WP_Post or an ID, so pass the context post's ID
when it is some other object, and declare the context post as an object.
docs/current-metrics.md follows the new first-party PHP line count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA2F1J2N3yCPk3cUX1P
It already reads any object with post_content; Psalm now accepts the
post from Yoast's context there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA2F1J2N3yCPk3cUX1P
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.42105% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.68%. Comparing base (ba065eb) to head (4b9063b).

Files with missing lines Patch % Lines
includes/json-ld-enrichment.php 68.42% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #252      +/-   ##
============================================
+ Coverage     88.64%   88.68%   +0.03%     
  Complexity       67       67              
============================================
  Files           102      102              
  Lines         10968    10982      +14     
  Branches        962      962              
============================================
+ Hits           9723     9739      +16     
+ Misses          447      445       -2     
  Partials        798      798              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

dknauss commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T17:24:14.892871Z 4b9063b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 4b9063bb52

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

dknauss pushed a commit that referenced this pull request Nov 6, 2026
measure.py read only 1-page.html, which the committed runs replace with
1-page-json-ld.json, so the published tables could not be recomputed
without the stack. It now falls back to the extracted JSON-LD and picks
Yoast's graph as the block with an @graph. Recomputing all four committed
runs reproduces their survival.json byte for byte.

The README now says the pr-252 rows need #252's context fix (78947a5 or
later) checked out, and keeps the main baseline run separate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA2F1J2N3yCPk3cUX1P
@dknauss
dknauss marked this pull request as ready for review November 6, 2026 17:48
@dknauss
dknauss merged commit 30a3948 into main Nov 6, 2026
22 checks passed
@dknauss
dknauss deleted the claude/project-thread-6zozsp-yoast-context branch November 6, 2026 17:48
dknauss added a commit that referenced this pull request Nov 6, 2026
* Trace citation metadata through Yoast SEO and NLWeb

Adds tools/yoast-nlweb-trace: a local WordPress 7.1 + Borges + Yoast SEO
28.8 + NLWeb site, built by setup.sh, and scripts that capture the
fixture post (the markup-value corpus) at each stage on the way to an
agent: the page's JSON-LD, Yoast's graph, Yoast's schema aggregator feed,
NLWeb's index (its own ingest code, from a crawl and from the feed), and
NLWeb's WordPress plugin answering an MCP `ask`. measure.py scores 78
field values per stage; probe.py checks which questions each stage can
still answer.

Today only titles (and DOIs inside @id URLs) get past Yoast: the full
records stay in Borges' ItemList, which NLWeb's trim drops. NLWeb's
WordPress plugin got no citations at all (fixed in #252). Two prototypes
show what putting full records into Yoast's graph would carry, and at
what page weight. No model was run: the ranking LLM is a recording stub.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA2F1J2N3yCPk3cUX1P

* Keep tools/ out of the persistence audit, and update the PHP line count

The trace site's setup scripts set WordPress and plugin options on the
throwaway site they build. tools/ is not in the release package, so the
no-persistence audit now skips it, as the metrics doc says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA2F1J2N3yCPk3cUX1P

* Trace tool: recompute from committed captures; pin #252 for prototypes

measure.py read only 1-page.html, which the committed runs replace with
1-page-json-ld.json, so the published tables could not be recomputed
without the stack. It now falls back to the extracted JSON-LD and picks
Yoast's graph as the block with an @graph. Recomputing all four committed
runs reproduces their survival.json byte for byte.

The README now says the pr-252 rows need #252's context fix (78947a5 or
later) checked out, and keeps the main baseline run separate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA2F1J2N3yCPk3cUX1P

---------

Co-authored-by: Claude <noreply@anthropic.com>
@dknauss dknauss mentioned this pull request Nov 6, 2026
dknauss added a commit that referenced this pull request Nov 7, 2026
In-text and margin citations with Update citations after a style change
(#256); annotated bibliographies (#258); h-cite microformats (#257); full
citation records in Yoast SEO's graph and Yoast context fix (#252, #254);
RIS journal abbreviations; sentence case in Harvard; the Playground demo
example of citations and annotations (#259).


Claude-Session: https://claude.ai/code/session_01WPtgA1cnwP9mYKwaWniaFS

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants