Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6936607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:15:20+00:00 2026-05-27T12:15:20+00:00

I am creating a slideshow shortcode for my WordPress theme, but have run into

  • 0

I am creating a slideshow shortcode for my WordPress theme, but have run into a small issue. This is what the shortcode looks like:

[slideshow width=500]
    [slide]http://example.com/image1.jpg[/slide]
    [slide]http://example.com/image2.jpg[/slide]
    [slide]http://example.com/image3.jpg[/slide]
[/slideshow]

So, basically it is two different shortcodes (slideshow and slide), I need to set the width of each “slide” shortcode. How do I get the “width” attribute from the parent “slideshow” shortcode and pass it to each child “slide”?

    //Create slideshow wrapper div
    function shortcode_slideshow($atts, $content = null){  
        $return = '<div class="slideshow">';
        $return .= do_shortcode($content); 
        $return .= '</div><!-- end slideshow -->'; 

        return $return; 
    } 

    //Create each slide HTML 
    function shortcode_slide($atts, $content = null){
        $return = '<a class="dolightbox" href="'.$content.'">'; 
        $return .= '<img src="'.$content.'" /></a>'; 
        return $return; 
    }

    add_shortcode('slideshow', 'shortcode_slideshow');
    add_shortcode('slide', 'shortcode_slide');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:15:21+00:00Added an answer on May 27, 2026 at 12:15 pm

    Ended up using global vars to pass the value into the second shortcode function. I thought maybe there was a native WordPress method of doing it, but I apparently not.

    //Create slideshow wrapper div
    $globalWidth = NULL; 
    
    function shortcode_slideshow($atts, $content = null){ 
        extract(shortcode_atts( array('width' => ''), $atts));
        global $globalWidth;
        $return = '<div class="slideshow">';
        $return .= do_shortcode($content); 
        $return .= '</div><!-- end slideshow -->'; 
    
        return $return; 
    } 
    
    //Create each slide HTML 
    function shortcode_slide($atts, $content = null){
        global $globalWidth;
        $return = '<img width="'.$globalWidth.'" src="'.$content.'" />'; 
    
        return $return; 
    }
    
    add_shortcode('slideshow', 'shortcode_slideshow');
    add_shortcode('slide', 'shortcode_slide');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a Lisp syntax like DSL - very small specific application - but very
Creating this ajax styled wordpress portfolio theme and I'm a little stuck on how
Creating a voting system just like stackoverflow. Questions like this have been asking several
Creating extensions got much easier with Vs2010, but this seems not to be the
Creating a slideshow jQuery plugin, but having trouble getting it to work with more
I am creating this custom theme www.designislikethis.tumblr.com , which uses the jQuery Masonry and
Creating a call stack diagram We have just recently been thrown into a big
I am creating a simple slide show. I have done everything, but am struggling
I'm creating a slideshow where each slide can have: - a video or a
We're creating a slideshow in HTML/CSS/JS but it isn't working in Firefox for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.