Title: Using shortcode in functions.php
Last modified: June 17, 2024

---

# Using shortcode in functions.php

 *  Resolved [nickattfield](https://wordpress.org/support/users/nickattfield/)
 * (@nickattfield)
 * [1 year, 11 months ago](https://wordpress.org/support/topic/using-shortcode-in-functions-php/)
 * Hi,
 * I’m trying to a get a lightbox shortcode working with a the below string in my
   functions.php file:
 *     ```wp-block-code
       add_filter( 'woocommerce_attribute_label', 'custom_attribute_label', 10, 3 );
       function custom_attribute_label( $label, $name, $product ) {
           $taxonomy = 'pa_'.$name;
   
           if( $taxonomy == 'pa_size' )
               $label .= '<div class="custom-label">' . __('MY TEXT', 'woocommerce') . '</div>';
   
           return $label;
       }
       ```
   
 * The idea being that next to the ‘MY TEXT’ it would say ‘MORE INFO’ and if you
   click on that that lightbox would pop up with a sizing diagram.
 * I can see on the SU docs, that shortcodes can be used in template files here:
   [https://getshortcodes.com/docs/using-shortcodes-in-template-files/](https://getshortcodes.com/docs/using-shortcodes-in-template-files/)
 * Would it be something like this (using the example lightbox shortcode from the
   site?
 * $content = ‘Click here to open lightbox with an image’;
   $my_shortcode = ‘[su_lightbox
   type=”image” src=”[https://placekitten.com/720/480″%5D&#8217](https://placekitten.com/720/480″%5D&#8217);.
   $content . ‘[/su_lightbox]’;echo do_shortcode( $my_shortcode );
 * And if so, but where do I need to add that into the code string to allow the 
   lightbox shortcode to work?
 * TIA
 * Nick

The topic ‘Using shortcode in functions.php’ is closed to new replies.

 * ![](https://ps.w.org/shortcodes-ultimate/assets/icon-256x256.gif?rev=2547563)
 * [Shortcodes Ultimate - Content Elements](https://wordpress.org/plugins/shortcodes-ultimate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcodes-ultimate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-ultimate/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-ultimate/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [nickattfield](https://wordpress.org/support/users/nickattfield/)
 * Last activity: [1 year, 11 months ago](https://wordpress.org/support/topic/using-shortcode-in-functions-php/)
 * Status: resolved