Axios toolkit for WordPress REST API

As I’m learning the deep workings of the WordPress REST API I’m also learning how to use Axios as a replacement for Fetch. While I discovered that this will not work with Nuxt and the WordPress REST API, it’s still a good starting point if you want to work with vanilla JS and templating engines. I am still researching how to make it work in Nuxt.js. Another thing that’s important to note. Other than getJWT() all other functions require authentication and I’ve chosen to use JSON Web Tokens (JWT) to authenticate the requests. The WordPress site uses the JWT Authentication

New research into block development

While researching block-based themes I found more information about blocks themselves and how to write them in a way you can submit them for inclusion in the WordPress directory. Most, if not all our blocks, will not be dynamic so we won’t cover them in this post, just mention them in case that’s what you’re looking for. See creating dynamic blocks for more information Creating blocks with external metadata The block type metadata provides an external means to declare our block API that will also be necessary if you decide to submit it to the block directory. The metadata is

Gutenberg Full Site Editing and Block-Based Themes

Note Right now block-based themes and full site editing are still work in progress. I write about it because, sooner rather than later, themes will take advantage of full site editing and they will become a new tool in the arsenal for WordPress developers. These features are not part of Core WordPress, they require the latest Gutenberg plugin (not the version that is bundled with WordPress), and the APIs discussed in this post may change before they are merged into core and become official parts of WordPress. An experimental feature available in recent versions of Gutenberg is the ability to

:is() CSS pseudo-class

There are times when we want the same element across the page to do the same. The following block styles the h2 elements inside the header, footer and main elements. header h2, main h2, footer h2 { color: red; } It works but it’s error-prone, repetitive and may cause all rules to be ignored if there is a mistake. Published in Selectors Level 4, the :is() pseudo-classtakes a selector list and selects any element that matches any of the selectors in that list. Using :is() e can write the previous example like this :is(header, main, footer) h2 { color: red;

Revisiting Gutenberg blocks (part 3): other thoughts about Gutenberg

This post about Gutenberg is a mix of different thoughts, ideas and code snippets I’ve worked on while researching how to build blocks for a project I’m working on. Making Custom Post Types work in Gutenberg I’ve created several custom post types that worked in the classic editor. When I brought them to my Gutenberg playground they would not work or they would not work as I expected them to. It took me a while to realize that you must be really picky on how you configure the Custom Post Type (CPT) to work as Gutenberg is far less forgiving