Advanced: How to modify shortcode template?

StartApp mostly built with shortcodes. Shortcode is a small and self-contained element that can be placed anywhere on the page. A small blocks from which you can build a stylish and unique site. But it is impossible to cover all the requirements under the theme. That's why if you need even more uniqueness (or, for example, fix a small issue) you can modify the templates on your own.

StartApp contains of two types of shortcodes:

  • Our brand shortcodes, developed for StartApp
  • Shortcodes, which comes with Visual Composer

Modifying Visual Composer's shortcodes

The Visual Composer works by using template files for the output of all it’s shortcodes which can be overwritten via themes. So you’ll need to place the original file in your child theme.

  1. Create new folder /vc_templates in your child theme
  2. Locate the template inside the Visual Composer plugin at /js_composer/includes/templates/shortcodes/
  3. Copy and paste template in the /vc_templates folder of your child theme
  4. Modify the template.

NOTE: StartApp already modified some templates to fix some design issues and also to add some extra options that weren’t present. You can check modified templates in /startapp/vc_templates/

Modifying brand shortcodes

All StartApp's shortcodes are located in the StartApp Core plugin. When shortcode displayed on the front-end this will trigger the shortcode's template loader. It detects the shortcodes name and searches the template in the following directories:

  • /startapp-child/shortcodes/
  • /startapp/shortcodes/
  • /startapp-core/shortcodes/templates/

First found template will be loaded. That's why if you need to modify StartApp shortcode template you can do the following:

  1. Create new folder /shortcodes in your child theme.
  2. Locate the template in StartApp Core plugin at /startapp-core/shortcodes/templates/
  3. Copy and place this template in /shortcodes folder of your child theme
  4. Modify the template! 

Now template loader will use overwritten template.

 Also you can add your own locations to the template loader. For example, you don’t like using child theme’s for one reason or another or you want to tweak a theme via a plugin you can use the filter:

 * Add custom locations to shortcode template loader
 * @param array $locations
 * @return array
function startapp_child_custom_shortcodes_location( $locations ) {
   // add to the beginning of a list
   array_unshift( $locations, '/my/custom/location' );
   // add to the end of a list
   $locations[] = '/my/custom/location';
   return $locations;
add_filter( 'startapp_shortcode_template_dirs', 'startapp_child_custom_shortcodes_location' );

Related articles

Advanced: Cache in shortcodes

Advanced: How to modify shortcode mapping?