Quantcast
Channel: Tishonator
Viewing all articles
Browse latest Browse all 293

How to Add Widgets inside Slides

$
0
0

By default our themes comes with Customizer options for Slides content such as Slide Background Image, Title, Text, Link URL, etc. In some cases you may want to insert widgets as slide content. Here is a guide how it can be done:

Login to your Admin Panel and navigate to Left Menu -> Appearance -> Editor, then open functions.php for editing.

Below the following code:

// II. Register Widget Areas

Insert:

// II. Register Widget Areas

for ($i = 1; $i <= 5; ++$i) {

  // Add Slide #i Widget
  register_sidebar( array (
   'name' =>
  sprintf( esc_html__( 'Slide #%s',
              'tishonator' ), $i ),
   'id'    =>  'slide-'.$i.'-widget-area',
   'description'   => 
sprintf( esc_html__( 'The Slide #%s widget area',
'tishonator' ), $i ),
        'before_widget'  =>  '',
        'after_widget'   =>  '',
        'before_title'   =>  '<h2>',
        'after_title'   =>  '</h2>',
      ) );      
}

Then below the following code:

<h2><?php echo $slideTitle; ?></h2>

insert:

<h2><?php echo $slideTitle; ?></h2>

<?php dynamic_sidebar( 'slide-'.$i.'-widget-area' ); ?>

Then Navigate to Left Menu -> Appearance -> Widgets and Insert widget you want in some of the available Slide # widget areas:

insert widget in slide

and Save changes.


Viewing all articles
Browse latest Browse all 293

Trending Articles