Define block templates for new pages, posts, and custom post types

WordPress’ block editor comes with the feature of block templates. This allows us to defined a set of blocks that will be present in the content of new pages, posts and/or custom post types. This post shows you how to use that functionality and how to use reusable blocks in templates.

Continue reading "Define block templates for new pages, posts, and custom post types"

Using the official PHP library for the WooCommerce REST API with basic auth

If a WordPress installation is protected via .htaccess basic auth, the requests against the WooCommerce REST API with the PHP library do not work. I did not find the GitHub issue where someone said that CURL could be used to set the login credentials, but with that information, I found a question and the answers on Stack Overflow, that helped me:

$ch = curl_init(); curl_setopt( $ch, CURLOPT_USERPWD, 'user:password' );
Code language: PHP (php)

I inserted these two lines at the beginning of my script and replaced user and password with the actual login data. With that, the requests against the protected installation worked.

Creating theme editor styles for Gutenberg

WordPress 5 will come with a new editor called »Gutenberg«, which is completely different from the current TinyMCE. That does not only mean change for the users, but also for theme developers, who want to modify editor styles, so it looks like in the frontend. This post shows you how that works for the new editor.

Continue reading "Creating theme editor styles for Gutenberg"