How to customize the URL for galleries
Over the years, it has become apparent there are as many client gallery configurations needed as there are photographers in the world. As a result, a Sunshine Photo Cart mantra is to be as flexible as possible for photographers to create the exact client gallery experience they want for their customers. Built into WordPress is the ability to customize URLs and the Sunshine Photo Cart WordPress plugin extends that for the galleries your customers view.
By default, Sunshine sets up URLs to follow a hierarchical structure so that a gallery URLs look like this:
yourwebsite.com/client-galleries/gallery/your-gallery
Simple gallery URL customization options
Changing the "client-galleries" URL part
This URL structure is built based on the main Client Galleries page that is created by default when you installed Sunshine Photo Cart and acts as the foundational page to show all your galleries. If you want to customize the "client-galleries" part, you can edit the slug for this page. Go to Pages > Client Galleries > Edit and change the permalink:
Changing the "gallery" part of the URL
This "base" part of the URL is handled within the Sunshine settings, specifically go to Sunshine > Settings > Pages & URLs. Here you will find the option to customize the gallery base URL part (along with a few others if you wish).
Changing the "your-gallery" part part of the URL
You can also edit the permalink for an individual gallery, or the "your-gallery" part in the sample URL above, by finding the same setting while editing your gallery. By default this is set based on the name of the gallery, but you can change it to anything you want.
Complete, code-based URL customization
The great thing about WordPress is how flexible it is and all the ways it allows everything to be customized. In the following code, you can have complete control over the base URL structure of your galleries if you want further specific structure.
The following code will make your gallery URLs look like:
yourwebsite.com/gallery/your-gallery
add_filter( 'sunshine_gallery_post_type_args', function( $args ){
$args['rewrite']['slug'] = 'gallery';
return $args;
});
Learn how to add this custom code to your WordPress website
After applying this custom code, go to Settings > Permalinks and simply hit save (no changes needed) so WordPress will recognize this change in your URL structure.
The one caveat with WordPress is you must have some kind of "base" part of the URL for each gallery and you cannot have gallery URLs that look like yourwebsite.com/your-gallery as the non-prefix structure is reserved for Pages on your site. This prefix tells WordPress what kind of content to display based on the URL.
Still need help?
If you have not yet found your answer in the documentation articles, please contact support