Viewers: in countries Watching now:
The many ways visitors access web sites, via mobile devices, tablets, and desktops, now requires sites to incorporate responsive design elements that adapt to different screen sizes and browsers. In this course, Morten Rand-Hendriksen demonstrates design strategies, best practices, and actual code examples for creating a responsive web site. The course covers layout, navigation, responsive video embedding, and content sliders. The final chapter shows how to create an index page with jQuery Masonry, a jQuery plugin that helps you create dynamic grid layouts.
Let's take a look at how you can include FlexSlider into the Anaximander theme, or any other theme for that matter. The first thing we need to do is get FlexSlider itself, and we get it here at woothemes.com/flexslider. This, by the way, is also where you'll find all the documentation and examples and other information. And the amount of stuff you can do here is quite extensive, so it's worth taking a close look at the site. So, I am going to download FlexSlider here, and get it onto my computer, and then I'll open this folder.
So, we'll go to functions.php, scroll all the way to the bottom, make some space, and here I want to add the functions to call FlexSlider in. Just like before, this requires quite a bit of code, so I've compiled it all for you, and you just have to copy it and paste it in. So you see here under 10.01, you'll find the FlexSlider code. Just go down and copy all of it and paste it in to functions.php. If we take a quick look at this function, it's exactly the same type of function that we saw previously with FitVids.
We have the function itself, aximander_flexslider. It's called down here add_action. On initiation, we call anaximander_flexslider. And here we do that register_script function again, where we give the script a name, we call it from the template_directory, and it's called then jquery.flexslider_minified. We enqueue that script, and then we also enqueue the style sheet. So we go wp_register_style, give the style a name, point to the style, template_directory css/flexslider.css, and then we enqueue the style here.
Finally, we have to add the script function, and this is where, if you want to customize FlexSlider further, you would add your extra script, because if you go into the examples of what is possible with FlexSlider, you'll see there's tons of extra functionality you can hook into if you want to and you can make lot of customizations with this tool. If you do that, this is where you would place it. But for now, we're just going to save it and then we have to add some content to our page that can be inside the FlexSlider.
To do that, I am going to go and modify index.php. That's the template file that controls the front page. So, I'll go back to my theme, find index.php, edit it with Notepad, and then directly under div content main here, I am going to add some new lines, and then here I'm going to paste in some dummy content. Back in my code_snippets file, I've already created that dummy content for you. So, you can just copy out from the beginning comment till the end comment here and paste it in, and you'll see all we're doing here is creating a divider with the class FlexSlider that has an unordered list with a class slides, and each of the list items within this unordered list will be one of the slides.
You can also see that each of the list item has an image and then a caption. When I save this and reload my page in my browser, you see FlexSlider appears at the top. And right now, FlexSlider is pulling images directly from my Flickr account. And we can even navigate between the images using either of these navigation buttons or by using the buttons down here on the bottom. But the coolest thing is, as I said before, FlexSlider, as the name suggests, is responsive and flexible, which means simply by adding FlexSlider into the site, like we just did, you automatically have a fully responsive slider.
Before we go any further, I want to say two things. First of all, you should go check out the live demo of FlexSlider, because you'll see that you have a lot of different options when it comes to how you want to use FlexSlider. You have the standard version, which is what we just included, and you can also add things like thumbnail navigation or even add a carousel that cycles through multiple pieces of content. All the documentation for these types of behaviors, along with code examples like the one you see right here, can be found on the FlexSlider web site.
And there is one more thing I want to point out. FlexSlider is a perfect example of an open source application in constant development. That means there are always developers working on improving FlexSlider, so chances are, if you implement it, it may not work exactly the same way that I'm showing you. But that also means it probably has even more features and is even more advanced. So, if you want to use FlexSlider, be sure to go to the web site, download the latest version, read the documentation, and make sure you're using it to its fullest.
There are currently no FAQs about WordPress: Building Responsive Themes.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.