Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Sage 9 Slider with Slick
@php(the_content())
@if($images)
@include('partials/slider')
@endif
<?php
namespace App;
/**
* Super Simple Slider
*
* Uses Advanced Custom Fields image gallery field, but this
* can be extended to pretty much anything else.
*
* @param $data
*
* @return mixed
*/
function slider( $data ) {
$images = get_field('images');
if ( $images ) {
$data['images'] = $images;
}
return $data;
}
add_filter( 'sage/template/page/data', 'App\\slider' );
<ul class="list-unstyled slider">
@forelse($images as $image)
<li class="card">
<img class="card-img-top" src="{{$image['url']}}" alt="{{$image['alt']}}">
<div class="card-block">
<h4 class="card-title text-center">{{$image['caption']}}</h4>
</div>
</li>
@empty
<li class="alert alert-danger">No Images</li>
@endforelse
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment