REST API – Head Tags
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: Yoast SEO – (up to 13.5) All in One SEO Pack – (up to 3.4.2) WP SEO – 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: Hello wordl! - My Site " /> 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": " " } } ] 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 About Frontity Framework Guide on SEO for Headless WordPress Themes Follow Frontity on Twitter and GitHub Get help on the Frontity Community Forum
Top keywords
- tags20×2.52%
- head17×2.14%
- head tags15×1.89%
- cache10×1.26%
- api9×1.13%
- rest9×1.13%
- rest api9×1.13%
- seo9×1.13%
- wordpress9×1.13%
- field7×0.88%
- frontity7×0.88%
- case6×0.75%
REST XML-RPC Data Checker
JSON REST API and XML-RPC API are powerful ways to remotely interact with WordPress. If you don’t have external applications that need to communicate with your WordPress instance using JSON REST API or XML-RPC API you should disable access to them for external requests. In the standard WordPress installation JSON REST API and XML-RPC API are enabled by default. In particular the REST API is turned on also for unlogged users. This means that your WordPress instance is potentially leaking data, for example anyone could be able to: copy easily your published contents natively with the REST API (and not with a web crawler); get the list of all users (with their ID, nickname and name); retrieve other information that you didn’t want to be public (such as an unlisted published page or a saved media not yet used). Even if you could do the stuff by writing your own code using native filters, this plugin aims to help you to control JSON REST API and XML-RPC API accesses from the administration panel or programmatically by a simple API filter. Basic Features Disable REST API interface for unlogged users. Disable JSONP support on REST API. Add Basic Authentication to REST API. Remove REST tags, REST Link HTTP header and REST Really Simple Discovery (RSD) informations. Setup trusted users, IP/Networks and endpoints for unlogged users REST requests. Change REST endpoint prefix. Disable XML-RPC API interface. Remove to the Really Simple Discovery (RDS) informations. Remove X-Pingback HTTP header. Setup trusted users, IP/Networks and methods for XML-RPC requests. Show user’s access informations in users list administration screen. Usage Once the plugin is installed you can control settings in the following ways: Using the Settings->REST XML-RPC Data Checker administration screen. Programmatically, by using rest_xmlrpc_data_checker_settings filter (see below). API Hooks rest_xmlrpc_data_checker_settings Filters plugin settings values. apply_filters( 'rest_xmlrpc_data_checker_settings', array $settings ) rest_xmlrpc_data_checker_admin_settings Filter allowing to display or not the plugin settings page in the administration. apply_filters( 'rest_xmlrpc_data_checker_admin_settings', boolean $display ) rest_xmlrpc_data_checker_rest_error Filter JSON REST authentication error after plugin checks. apply_filters( 'rest_xmlrpc_data_checker_rest_error', WP_Error|boolean $result ) xmlrpc_before_insert_post Filter XML-RPC post data to be inserted via XML-RPC before to insert post into database. apply_filters( 'xmlrpc_before_insert_post', array|IXR_Error $content_struct, WP_User $user )
Top keywords