Skip to content

How to apply custom code for Sunshine Photo Cart

One of the great things about WordPress is it's ability to be customized. It's one reason Sunshine Photo Cart was built as a WordPress plugin because it gives you, the photographer, more control over exactly how you want your client galleries to perform. Sunshine has many features and customization options out of the box, but sometimes you need to go a little further and implement some custom code.

Adding custom CSS code

CSS stands for Cascading Style Sheets and is what defines the layout, colors, sizes of elements on the page. Sunshine makes it easy to add custom CSS rules that only apply on Sunshine related pages by going to Sunshine > Settings > Design and entering the code into the Custom CSS box.

Adding custom PHP code via Code Snippets Plugin

With any code samples provided within these documentation or in via support, it is recommended to use the Code Snippets plugin to quickly and easily implement any custom code for your site without any technical knowledge.

How to add your custom PHP code snippet

  • Install and activate the Code Snippets plugin
  • Go to Snippets > Add New
  • Enter any title you wish
  • Copy/paste the code into the Functions (PHP) tab
  • Click "Save changes and Activate"

Adding custom PHP code via your own custom plugin

If you’re comfortable writing a little code, you can create your own mini plugin. This keeps all your custom code separate from themes and other plugins and is often a standard approach for professional WordPress developers.

  1. On your computer, create a file called something like custom-sunshine.php.
  2. Add this to the top of the file:
<?php
/**
 * Plugin Name: Sunshine Custom Code
 * Description: Custom code snippets for Sunshine Photo Cart.
 * Author: Your Name
 */

// Your custom code goes below this line.

Learn how to add this custom code to your WordPress website

  1. Add your code below that header.
  2. Add the plugin to your site either by:
    • FTP the file to your wp-content/plugins folder
    • Zip the file, then upload it to your site under Plugins → Add New → Upload Plugin.
  3. Activate it like any other plugin.

This way, your customizations will stay safe during theme or plugin updates.

Adding Code to Your Theme’s functions.php File

You can also add code directly to your theme’s functions.php file. This works, but it comes with a warning:

  • If you update your theme, your changes may be overwritten.
  • If you switch themes, your code won’t come with you.

If you go this route, it’s best to use a child theme so your changes are preserved when the parent theme updates.

Still need help?

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

Sunshine Photo Cart for WordPress