Last active
December 26, 2015 02:28
-
-
Save jamiemitchell/7078280 to your computer and use it in GitHub Desktop.
Add Flexslider to front page in Genesis. Not fully tested but should work, you will need to style it. Add head scripts to the same page template.
This file contains hidden or 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
<?php | |
/* Add slider | |
------------------------------------------------------------ */ | |
add_action('genesis_after_header', 'jm_home_slider'); | |
function jm_home_slider() { | |
echo '<div id="featured-slider">'; | |
echo '<div class="flexslider">'; | |
echo '<ul class="slides">'; | |
$args = array( | |
'post_type' => 'slide', | |
'order' => 'DESC', | |
); | |
$tips = new WP_Query( $args ); | |
if( $tips->have_posts() ): | |
while ( $tips->have_posts() ) : $tips->the_post(); | |
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); | |
echo '<li class="slide'; | |
echo '" style="background:center top url('.$image[0].'); background-size: cover; height:'. $image[2].'px;"'; | |
echo '>'; | |
echo '<div class="flex-caption"><div class="wrap">'. apply_filters('the_content',get_the_content()) .'</div></div>'; | |
endwhile; | |
endif; | |
wp_reset_postdata(); | |
echo '</ul>'; | |
echo '</div>'; | |
echo '</div>'; | |
} |
This file contains hidden or 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
<?php | |
/* Enqueue scripts | |
------------------------------------------------------------ */ | |
add_action( 'wp_enqueue_scripts', 'frame_front_page_enqueue_scripts' ); | |
function frame_front_page_enqueue_scripts() { | |
wp_enqueue_script('flexslider', get_stylesheet_directory_uri().'/lib/js/jquery.flexslider-min.js', array('jquery'), '2.1', TRUE); | |
wp_enqueue_style('flexslider-style', get_stylesheet_directory_uri().'/lib/js/flexslider.css','flexslider','2.1'); | |
wp_enqueue_script('flexslider-init', get_stylesheet_directory_uri().'/lib/js/flexslider-init.js', array('jquery'), '2.1', TRUE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment