One of the most popular uses of JavaScript on a WordPress site is to create a content slider that shows particular types of posts or media. Some of the most popular sites use this effect, including eBay, Amazon, and ESPN.
For this recipe, you need to have already created a theme, and decided where you'd like to put your featured content slider. In addition, you should have a special category that you assign to posts that you want to be featured.
First, you need to identify which set of posts will be part of your featured content slider. For the purposes of this recipe, we're going to assume that you assign all featured posts a category of Featured
, which has a category ID
of 3
. Next, you need to create a file to hold the code. Create a file, and name it featured-slider-markup.php
.
Now, to define the markup for the featured content slider, open the featured-slider-markup.php
file, and insert the following code:
<?php $featured_query...