Last active
August 29, 2015 14:01
-
-
Save puikinsh/304c2b66089dfdb3612e to your computer and use it in GitHub Desktop.
Sparkling Slider customizations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I will leave this code here to avoid encoding issues you might face when copying from Gmail | |
You can create flexslider customizations by creating a new file in child theme and enqueue it like this: | |
add_action( 'wp_enqueue_scripts', 'sparkling_child_script' ); | |
function sparkling_child_script() { | |
wp_enqueue_script( 'sparkling_child_slider', get_stylesheet_directory_uri() . '/js/newflex.js', array( 'jquery' ), '2.2.2', true ); | |
} | |
Newflex.js file itself should look like this: | |
jQuery(function($){ | |
// Flexslider init | |
if( $('.flexslider').length ) { | |
$('.flexslider').flexslider({ | |
slideshow: true, | |
animation: "slide", | |
directionNav: true, | |
smoothHeight: true | |
}); | |
} | |
}); | |
You can tweak this as you want with more flexslider functions. | |
I will release Sparkling 1.4.1 update with fix for slider to make it easier to overwrite via Child Theme. Version 1.4 is already approved and should go live any minute. I will wrap original function with if functions_exists, so you can copy/paste and midify it via Child Theme. I hope you don't mind about that. | |
It will look like this | |
if ( ! function_exists( 'sparkling_featured_slider' ) ) { | |
// Featured image slider | |
function sparkling_featured_slider() { | |
if ( is_front_page() && of_get_option('sparkling_slider_checkbox') == 1 ) { | |
echo '<div class="flexslider">'; | |
echo '<ul class="slides">'; | |
$count = of_get_option('sparkling_slide_number'); | |
$slidecat =of_get_option('sparkling_slide_categories'); | |
$query = new WP_Query( array( 'cat' =>$slidecat,'posts_per_page' =>$count ) ); | |
if ($query->have_posts()) : | |
while ($query->have_posts()) : $query->the_post(); | |
echo '<li>'; | |
if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) : | |
echo get_the_post_thumbnail(); | |
endif; | |
echo '<div class="flex-caption">'; | |
echo '<a href="'. get_permalink() .'">'; | |
if ( get_the_title() != '' ) echo '<h2 class="entry-title">'. get_the_title().'</h2>'; | |
if ( get_the_excerpt() != '' ) echo '<div class="excerpt">' . get_the_excerpt() .'</div>'; | |
echo '</a>'; | |
echo '</div>'; | |
endwhile; | |
endif; | |
echo '</li>'; | |
echo '</ul>'; | |
echo ' </div>'; | |
} | |
} | |
} | |
More Child Theme friendly theme version is already on Github: https://github.com/puikinsh/Sparkling | |
From there you can use regular function: | |
function sparkling_featured_slider() | |
And it will overwrite existing function from extras.php. | |
This version will go live withing few days on WordPress.org as well. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment