Displaying a slider in your category pages

By default, the slider can be displayed before posts or pages in the Customizr theme but you might want to display a slider for a specific category (or for all).

The following snippet allows you to do so in two simple steps

1 First, create a slider and grab its name (see how to create a slider in Customizr )

2Then add one of the snippet below in your functions.php file.

 

Example 1 : displaying one slider for all categories

In the example below, just replace MY-SLIDER-NAME by your slider name.

 

Example 2 : displaying a different slider by categories

This snippet is a bit longer. It basically assigns a slider name for each category for which you want to display a slider.

Just replace the example values in the $category_list array with yours and you are done.

 

Important : the $category_list uses the category slugs (and not the names). For example, if you have been created a category named My Awesome Category, you will have to use my-awesome-category (which is the slug) in the $category_list array.

More about category slug in WordPress.

 

 

Where to paste this code? => in your functions.php file. I strongly recommend to create a child theme. Download a start-up child theme here.

Everything you need to know about child theme with Customizr here.

25 thoughts on “Displaying a slider in your category pages”

Comments are closed.