• Resolved nickattfield

    (@nickattfield)


    Hi,

    I’m trying to a get a lightbox shortcode working with a the below string in my functions.php file:

    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/

    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; . $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

  • You must be logged in to reply to this topic.