Oxygen Builder Tutorial

Add Custom Categories to Oxygen Blocks

Get Help with Oxygen
Blue globe and ball image
Categories:
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(
        'Portfolio',
        'Products',
        'Gutenberg',
        'Features',
        'Menus',
        'Team',
    );

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

	sort($ct_component_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.

Phe Simmonds

Tutorial written by Phe Simmonds

Director & Web Developer at WinuSoft Web Design. When she's not working, Phe can usually be found mountain biking with her partner, Luis and dog, Bubba.
Blue background image Blue ball image

Other Tutorials

Blue circular lines

Get In Touch

Whether your business is just getting started or you’re in the middle of a growth spurt, we can design and develop a website that will help you scale.

"*" indicates required fields

Name*
This field is for validation purposes and should be left unchanged.
Copyright © 2024 WinuSoft Web Design
crosschevron-downarrow-right