How to make dynamic slider from static html slider in WordPress
Posted By : Satyam Sharma | 23-Dec-2018
In this blog, I will show you how to make a dynamic slider in WordPress using HTML static slider. When we are making any WordPress websites then sometimes we will not satisfied with slider plugin functionality or sometimes we liked an HTML slider but we didn't found any slider plugin which would be able to create that kind of slider. So, In that case, we should not have to worry because in this post I will show you how we can use that HTML static slider in WordPress and also make it dynamic for putting any kind of image what we want.
Here I am taking a bootstrap HTML slider code for showing you the example. So for creating slider just follow the given steps
For creating the slider first we need to select any HTML slider and paste that slider into our WordPress PHP file like you can put the code into header file or custom template file or wherever you want.
Now here I am cutting the other slide code and leave there for only first slider code because here we will using the WordPress loop method for the show all slides.
Now the third step is creating a custom post type by giving the name of the Slider. We are creating it because we have to give the options for change slide images or text from WordPress backend. So for creating the custom post type we are using a WordPress custom post type function which name is register_post_type by passing the required parameter in it. we are putting this code into WordPress functions.php file.
After creating the custom_post_type with the name of slider make some post in the backend in slider post type and also put the image in set featured image options.
Now, this is the final and very important step because in this step we are making the slider dynamic after that step you can customize slider texts and images my own. So follow this step carefully.
In the above code, we have put our item class in WordPress while loop for our dynamic slider post type. which will help to call all post one by one and showing them as a slide
Note: Just remove the active class from the item and use a jquery method for putting active class only for the first item in the slider.
So overall if look the code we will not find any hard code which could make any confusion in your mind to understand. We just have put an HTML static slider code then we made a dynamic slider post type in wp backend panel than called them in while loop. So overall it's not much difficult if you have followed these steps properly then you can make any HTML static slider dynamic