Category: WordPress

  • Adding conditional menu items to WordPress menus

    Here’s what I wanted to do: give clients the ability to add conditional items to menus and be clear about which users will see which items on the front end menu. For example, I want some menu items which only show for logged in users and some which only show for users who have bought…

  • What use is anything without columns

    As expected, Gutenberg blocks with inner blocks, eg columns, weren’t working. Like other bits, this was somewhat straightforward once I figured out how. It took me a while and with more than a few infinite loops thrown in to make it that much more frustrating. What I ended up is copying the render_blocks function from…

  • Gutenberg and Gatsby sitting in a tree…

    This is about WordPress and the static site generator Gatsby, not the Gutenberg and Gatsby you might know. I’m not sure where that post would go. Anyway. Parsing Gutenberg blocks in Gatsby turns out to be much more straightforward than I thought it would be. Not that it’s completely straightforward, but I didn’t find it…

  • WP blocks, raw data and the auths

    I’m at the point now where I want to try parsing the raw content of the posts with the new editor / Gutenberg block data. The endpoints with posts in both the REST API and wp_graphql contain a field with the data needed but that’s only accessible to users with the edit_posts and maybe a…

  • Shortcodes? WP Blocks? Server side rendering?

    I have a Prism.js block that I quite like, it’s part of a series of goofy ass Gutenberg blocks I made so long ago they probably don’t even work anymore. They’re working again. Most of it was Gutenberg backwards compat breaks, some was other back compat breaks, some was forgetting what I did in the…

  • Playing around with WP, Gatsby and Netlify

    This should be a nice explanation of what I’m doing but it’s not, I just wanted a different post at the top of the home page. 💖✨👍 Repo here https://github.com/tharsheblows/gatsby-test

  • Using Gutenberg blocks in place of custom metaboxes in WordPress

    Custom metaboxes are used extensively in WordPress for layout purposes as well as data structure. However, they don’t necessarily — in fact they rarely — save to the meta key’s array of objects when they’re added to the WordPress REST API and can’t be used by Gutenberg’s built in meta attribute. How can we use Gutenberg with…

  • register_meta(), register_rest_field() and the WP REST API

    There are two standard ways to add additional data into a post’s object in the WP REST API: register_meta() for post meta which is a string, number or boolean and register_rest_field()for everything else. There’s a bit on the difference between the two in the REST API docs. With Gutenberg, register_meta() is being used more widely and there’s…

  • “This block has been modified externally” notice of death in Gutenberg

    This notice drove me insane, especially because I couldn’t quite figure out what was being compared. It turns out it’s that the save function in registerBlockType() compares its return value to whatever is between the block’s html comment tags in the database.

  • Using Select2 with ajax with CMB2 repeating groups

    No idea if the title makes sense. I wanted a Select2 which uses a remote data source queried via ajax with a CMB2 repeating group so made a plugin to understand it better. It’s pretty heavily commented so I don’t forget why I did what I did. There are definitely a few if not many…