12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Apr 27, 2020

Filterable Slider in Oxygen using Flickity

Sridhar Katakam

This members-only tutorial provides the steps to implement this codepen for a dynamic responsive slider/carousel showing featured image and titles of the specified Custom Post Type entries filterable by an associated taxonomy using Flickity.

In this example we shall show movies that can be filtered by the movie category.

Note: The tutorial has only been tested with one instance of the filterable slider per page. You may need to do some code adjustments for having more than one instance of a page.

Step 1

Let us register a custom image size for the images in our slider.

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: Custom image sizes

Code:

add_image_size( 'flickity_slider_image', 800, 500, true );

Save changes and activate.

If you set featured images by uploading new ones to the entries of the CPT after implementing the tutorial, you will need to regenerate thumbnails.

Step 2

Let us define a custom function that takes in a taxonomy name and outputs the HTML for showing the row of term filters.

With this function we can just place

wpdd_output_term_filters( 'movie_category' );

in Oxygen's Code Block component and have sample HTML like the following be output:

<div class="filter-buttons">
	<button class="filter-button active" data-filter="all">All</button>
	<button class="filter-button" data-filter="children">Children</button>
	<button class="filter-button" data-filter="comedy">Comedy</button>
	<button class="filter-button" data-filter="drama">Drama</button>
	<button class="filter-button" data-filter="fantasy">Fantasy</button>
	<button class="filter-button" data-filter="mystery">Mystery</button>
	<button class="filter-button" data-filter="romance">Romance</button>
	<button class="filter-button" data-filter="sci-fi">Sci-Fi</button>
	<button class="filter-button" data-filter="thriller">Thriller</button>
</div>

Add another code snippet.

Title: [Function] Output Taxonomy Term Filters

Code:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right