When using WordPress as a headless CMS with a decoupled front-end (Next.js, Gatsby, Nuxt, etc.), SEO Forge data is accessible via the REST API.
Fetching SEO Data for a Post
bash
# Get analysis data including score and issues
curl -u "admin:ABCD 1234 EFGH 5678 IJKL 9012"
https://example.com/wp-json/seoforge/v1/analyze/42
# Get JSON-LD schema for embedding in your front-end
curl -u "admin:ABCD 1234 EFGH 5678 IJKL 9012"
https://example.com/wp-json/seoforge/v1/schema/42Reading Meta via Standard WP REST API
SEO Forge meta is stored as standard post meta, so you can expose it in the WP REST API:
php
// Register SEO Forge meta fields in the REST API response
add_action( 'rest_api_init', function () {
$meta_keys = [
'_seoforge_meta_title',
'_seoforge_meta_description',
'_seoforge_focus_keyword',
'_seoforge_noindex',
'_seoforge_schema_type',
];
foreach ( $meta_keys as $key ) {
register_post_meta( '', $key, [
'show_in_rest' => true,
'single' => true,
'type' => 'string',
'auth_callback' => function () {
return current_user_can( 'edit_posts' );
},
] );
}
} );Next.js Integration Example
javascript
// pages/[slug].js — fetching SEO data from WordPress
export async function getStaticProps({ params }) {
const postRes = await fetch(
`${process.env.WP_API_URL}/wp/v2/posts?slug=${params.slug}`
);
const posts = await postRes.json();
const post = posts[0];
const schemaRes = await fetch(
`${process.env.WP_API_URL}/seoforge/v1/schema/${post.id}`,
{ headers: { Authorization: `Basic ${process.env.WP_AUTH_TOKEN}` } }
);
const schema = await schemaRes.json();
return {
props: {
post,
seoTitle: post.meta?._seoforge_meta_title || post.title.rendered,
seoDescription: post.meta?._seoforge_meta_description || '',
schema,
},
};
}Disabling Front-End Output for Headless
When using WordPress headlessly, you do not need wp_head output:
php
// Disable all SEO Forge front-end output (use REST API instead)
add_action( 'init', function () {
if ( ! class_exists( 'SEOFORGE_Core' ) ) { return; }
// Keep REST API and analysis, disable HTML output
if ( class_exists( 'SEOFORGE_Meta_Generator' ) )
remove_action( 'wp_head', [ SEOFORGE_Meta_Generator::instance(), 'output_meta_tags' ], 1 );
if ( class_exists( 'SEOFORGE_Schema' ) )
remove_action( 'wp_head', [ SEOFORGE_Schema::instance(), 'output_schema' ], 5 );
if ( class_exists( 'SEOFORGE_Robots_Meta' ) )
remove_action( 'wp_head', [ SEOFORGE_Robots_Meta::instance(), 'output_robots_meta' ], 2 );
}, 20 );—