DEV Community

Bruce Axtens
Bruce Axtens

Posted on

WordPress REST API, meta and <META>

I need help with WordPress's REST API.

In their handbook, in the Endpoint Reference for Pages there's a schema and in that schema there's a table with a row that says

meta
object
Meta fields.
Context: view, edit

No further mention of meta is made and no instructions are given on how it may be used or in what format its arguments need to be given.

Questions:

  1. Is this meta the same as the HTML markup <META?
  2. Can meta be used to provide data that would be used in a <META whether it be a description or a keywords or whatever?
  3. Where may be found examples of the use of the meta keyword in REST API view and edit calls for Pages and other Endpoints?
  4. How are arguments provided in meta to be formatted.
  5. If meta doesn't set <META, what may be used to update <META descriptions and keywords (that can be driven programmatically. Don't tell me about Yoast and other SEO tools.)

Top comments (4)

Collapse
 
daleran profile image
Sean M Davis • Edited

Meta is just a key-value you can tack on to an individual post. Plugins use it to add additional information to a post instead of defining a separate database table. There is some info about the meta db tables here: code.tutsplus.com/tutorials/unders...

EDIT: Also, it has nothing to do with META html tags. To modify those, you just need to change whichever PHP template file contains the head tags. Just use PHP to set them to whatever you need. You could technically pull from post or user database meta data to populate the html meta tags. That's a method. Or use a hook to print them in wp_head().

Collapse
 
daleran profile image
Sean M Davis

And here is info on interacting with metadata via the API. torquemag.io/2015/07/working-with-...

Collapse
 
indrajoko21 profile image
joko warsito

Hi @bugmagnet

Is it possible if we embed SEO tags from headless wordpress to main website (React JS)? i'm currently facing issue to fetch SEO related tags on header

Collapse
 
bugmagnet profile image
Bruce Axtens

Sorry, way outside my expertise.