REST API – Head Tags

REST API – Head Tags

Wordpress plugin

Install on Wordpress

App Details

This plugin adds all the tags in the head section of a website to WordPress REST API responses.

It is perfect if you are using WordPress for a headless set-up and would like to add the meta tags generated by your WordPress SEO plugin (like Yoast SEO or All-in-One SEO Pack) to the WordPress REST API output.

Requirements

This package depends on the PHP DOM library. Most PHP environments have it by default so you don’t have to worry about that.

In case you get some errors regarding this dependency make sure you have this library installed (you can take a look at this thread in the code repository).

Compatibility

This plugin is compatible and works out of the box with some of the most popular WordPress SEO plugins. These are the ones that we tested:

Are you using a different SEO plugin and want to know if it’s compatible? Feel free to ask in our community forum. If you tested any other plugin, please let us know as well so we can update the list.

How to use this plugin

Entities with head tags

The plugin has been developed to include the head_tags field to the REST API response of most of the WordPress core entities:

  • Posts, pages, attachments and custom post types.
  • Post types: for archive pages.
  • Categories, tags and custom taxonomies.
  • Authors.

In a Frontity project

If you are using Frontity, you just have to install the @frontity/head-tags package and it will work automatically.

In a different project

You need to understand better how it works and add the data manually.

How to fetch the head_tags field manually

You have to get each entity from its respective REST API endpoint. For example: for fetching the posts, you should go to /wp-json/wp/v2/posts&id=123 endpoint; for fetching the categories, you have to go to wp-json/wp/v2/categories&id=123, and for custom post types or custom taxonomies, it would be a different url in each case.

In the case of the homepage, it’s less intuitive and you should go to /wp-json/wp/v2/types/post. As previously said, each entity has a different endpoint so if you aren’t familiar with this, you should check out the WordPress REST API reference for more information.

Inside each endpoint, it will be a new field named head_tags, which will be an array of objects representing the tags that WordPress would normally include inside the html head element. These objects have the properties tag, attributes and content.

For example for these HTML tags:

<title>Hello wordl! - My Site</title> <meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1"> <link rel="canonical" href="<https://test.frontity.org/>" /> 

This would be the content of the head_tags field:

"head_tags": [ { "tag": "title", "content": "Hello world! - My Site" }, { "tag": "meta", "attributes": { "name": "robots", "content": "max-snippet:-1, max-image-preview:large, max-video-preview:-1" } }, { "tag": "link", "attributes": { "rel": "canonical", "href": "<https://test.frontity.org/>" } } ] 

Settings

The settings of this plugin are really simple.

Purge cache

In order to not affect the performance of your site, the head_tags field is cached for all your responses. Each time you update a post/page/cpt or a taxonomy, the cache for that entity will be purged automatically. In case you make global changes (i.e. your permalinks or your global Yoast settings) use the Purge button to clean the whole cache.

Enable output

By default, the head_tags field is included in the common endpoint of each entity. You can configure it so it doesn’t appear by default and to be shown when you include the head_tags=true query.

For example, with the output disabled, https://test.frontity.org/wp-json/wp/v2/posts won’t show the head_tags field unless you have the query ?head_tags=true at the end.

Skip cache

In case you want to skip the cache, you can do so by adding to the query the parameter skip_cache.

There are some cache plugins for the REST API which also use the same parameter. In case you want to ignore the cache for the REST API call but not for the head tags, you can use skip_cache&head_tags_skip_cache=false.

Problems and Questions

If you have any trouble with the REST API – Head Tags, you can check out our docs or join our community forum and let us know. We’ll be happy to help!

Bug reports for REST API – Head Tags plugin are welcomed in our repository on GitHub. Before opening an issue, please be sure to review the contributing guidelines.

More Information

Pricing

Starting from $0 per month.

Check Out the Events Calendar Widget

By Common Ninja

Events CalendarTry For Free!

App Info

Rating

Reviewers

2 reviews

Tags

api
meta
rest
seo
Yoast

Developed By

Pablo Postigo

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Maps

Maps plugins for Wordpress

Translation

Translation plugins for Wordpress

Chat

Chat plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Contact

Contact plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Forms

Forms plugins for Wordpress

Comments

Comments plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Comments

Comments plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Video Player

Video Player plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Security

Security plugins for Wordpress

Ads

Ads plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Membership

Membership plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

Events Calendar for Wordpress logo

Events Calendar

Add an events calendar to your site so visitors can view upcoming activities, improving engagement and event visibility.

Reddit Feed for Wordpress logo

Reddit Feed

Show Reddit posts with a Reddit feed that updates automatically, improves content discovery, and keeps visitors engaged with fresh discussions.

Bluesky Feed Carousel for Wordpress logo

Bluesky Feed Carousel

Display Bluesky posts with a Bluesky feed carousel that auto updates, shows posts in a clear layout, and keeps visitors engaged.

Diagrams for Wordpress logo

Diagrams

Create interactive diagrams with a diagrams widget that lets you build and customize flow charts, improve clarity, and help visitors understand complex ideas easily.

Scroll Progress for Wordpress logo

Scroll Progress

Use a scroll progress bar that visually tracks reading on the page, improves navigation, and keeps visitors aware of their position.

HIPAA Compliance Forms for Wordpress logo

HIPAA Compliance Forms

Create secure HIPAA compliant forms that protect sensitive data, offer full customization, and integrate easily for safe medical information collection.

G2 Reviews for Wordpress logo

G2 Reviews

Show G2 reviews to build trust, strengthen credibility, and help visitors make confident SaaS buying decisions that support higher sales.

Lottie Player for Wordpress logo

Lottie Player

Use a Lottie player to embed lightweight JSON animations that improve visual design, keep pages fast, and create a smoother user experience.

Popup Builder for Wordpress logo

Popup Builder

Add customizable popups to your site to capture attention, deliver messages, and drive actions like signups or conversions.

Spinning Wheel for Wordpress logo

Spinning Wheel

Add an interactive spinning wheel to offer prizes, capture leads, and drive user engagement through gamified rewards.

Testimonials Slider for Wordpress logo

Testimonials Slider

Add a testimonials slider to your site to showcase real customer feedback, build credibility, and increase trust that leads to higher conversions.

Job Application Form for Wordpress logo

Job Application Form

Collect candidate information with a job application form that organizes submissions, streamlines hiring, and helps you manage applicants efficiently.

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms