Add Carousel Slider in Your Theme Manually

A member of WP Sites asked me how to install the jQuery and hook the slider in using PHP code.

In this tutorial, i’ll provide all the code in step by step instructions to install the the slider carousel which works like you see in the following video:

slides

Upload Slider Folder

Download Slider Folder

The 1st step is to download the slider zip file, unpack it and upload the folder to your child themes root directory so its in this location:

folder-location

Load Slider Files

Next step is to load all the files you need to make the slider work.

Add the following PHP code to your child themes functions.php file:

add_action( 'wp_enqueue_scripts', 'call_slider_script' );
function call_slider_script() {
if ( is_front_page() ) {
    wp_enqueue_script( 'call-slider-jquery', get_stylesheet_directory_uri() . '/slider/call-slider.js', array( 'jquery' ), '1.0.0' );
    wp_enqueue_script( 'slider-jquery', get_stylesheet_directory_uri() . '/slider/jquery.bxslider.js', array( 'jquery' ), '1.0.0' );
    wp_enqueue_script( 'slider-jquery-min', get_stylesheet_directory_uri() . '/slider/jquery.bxslider.min.js', array( 'jquery' ), '1.0.0' );
    wp_enqueue_style( 'slider-css', get_stylesheet_directory_uri() . '/slider/jquery.bxslider.css' );
    }
}

In the above code, we’ll only load the files on the front page.

Display Slides

Next step is to display the slider in your theme.

The 1st method enables you to hook in the HTML for the slides on the front page only by adding the following PHP code to the end of your child themes functions file:

Alternatively, you can create a new widget and add the HTML for the slider into a text widget populates in your slider widget area. Add the following code to your functions file if you prefer using a widget:

Once you create the new widget area, you can add the HTML for your slides wrapped in a div.


Comments

6 responses to “Add Carousel Slider in Your Theme Manually”

  1. realestateradioshow Avatar
    realestateradioshow

    Hi Brad, What would i have to change to hook it into Minimum Pro Front Page Custom-Tagline

    Or

    Create a function which includes the HTML and replace the custom field code with the function using this tutorial http://wpsites.net/web-design/replace-minimum-pro-themes-tagline-with-custom-field/

    1. Brad Dalton Avatar
      Brad Dalton

      Hello Greg

      Add the HTML for the images into a text widget after adding the widget to the tagline

  2. Brad, is there a way to just up load the slider with all its contents….or is this an example where I need to use cyperduck or filezilla?

    Thanks.
    Janet H.

    1. Brad Dalton Avatar
      Brad Dalton

      You can install a plugin if you don’t want to add the code manually.

      If you want to install the slider files manually, you need to follow the steps one at a time.

    2. Brad Dalton Avatar
      Brad Dalton

      One more thing, if you’re working locally, you don’t need Filezilla or any FTP program.

      Whats your domain name and what theme are you using?

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.