Skip to content

Enable tags/categories for galleries

Sunshine's default method for organizing galleries is my a parent/child hierarchical structure. However, if you want to assign galleries to categories/tags/custom taxonomy, you can do so following these steps:

Custom Taxonomy Setup (Recommended)

Use a 3rd party plugin like Custom Post Type UI. This allows you to create custom taxonomies for any post type. Create a new taxonomy and be sure to assign it to the "Sunshine Gallery" (sunshine-gallery) post type.

Built in Tags or Categories

WordPress allows for posts to have categories and tags by default. Sunshine Photo Cart creates a Custom Post Type "sunshine-gallery" for all it's galleries. Using the code below, you can enable the default tagging functionality for your galleries:

add_filter( 'sunshine_gallery_post_type_args', 'add_tags_to_sunshine_gallery' );
function add_tags_to_sunshine_gallery( $args ) {
	$args['taxonomies'] = isset( $args['taxonomies'] ) ? array_merge( $args['taxonomies'], array( 'post_tag' ) ) : array( 'post_tag' );
	return $args;
}

Learn how to add this custom code to your WordPress website

Or, you can use categories if you wish. Categories are hierarchical where tags are not.

add_filter( 'sunshine_gallery_post_type_args', 'add_tags_to_sunshine_gallery' );
function add_tags_to_sunshine_gallery( $args ) {
	$args['taxonomies'] = isset( $args['taxonomies'] ) ? array_merge( $args['taxonomies'], array( 'category' ) ) : array( 'category' );
	return $args;
}

Learn how to add this custom code to your WordPress website

Screenshot showing where tags are available in the WordPress admin when adding/editing a gallery
Tags/categories are now available in the right sidebar when adding/editing a gallery

Still need help?

If you have not yet found your answer in the documentation articles, please contact support

Sunshine Photo Cart for WordPress