Add Custom Categories to Oxygen Blocks

August 3, 2021
Add Custom Categories to Oxygen Blocks

Oxygen has a number of built-in categories that can be used for the items you create in the Block Library. However, you may find that you want to create additional categories for those blocks so that you can select from those categories when adding a block via the Design Library.

This is possible with a PHP snippet, so the first thing to do is to install the snippets plugin of your choice, such as Advanced Scripts (paid) or Code Snippets (free).

Once you've installed the plugin, create a snippet with the following code:

add_action('plugins_loaded', 'oxygen_custom_block_categories');

function oxygen_custom_block_categories() {
    global $ct_component_categories;
	$new_categories =  array(

	$ct_component_categories = array_merge($ct_component_categories, $new_categories);



You can replace the categories on lines #6 to #11 with your own categories as well as adding new lines so that you can create as many categories as you wish.

A small bonus is that the categories will be displayed in alphabetical order, which is what the "sort" code does on line #16. If you want the categories to remain in the normal order, you can delete that line.

Tutorial written by Phe Simmonds
Director & Web Developer at WinuSoft Web Design & Senior Support Specialist at Oxygen. When she's not working, Phe can usually be found mountain biking with her partner, Luis.

Get in Touch

Contact us about any web, design or branding project that you have in mind. If you're after custom development services for your Oxygen Builder site, we can help with that too!

We're sure that you'll find our approach and dedication will be just what you need. We’re always happy to discuss your project with you. Drop us an email or give us a call to get started.