Skip to content

Instantly share code, notes, and snippets.

@freezvd
Forked from jamiemitchell/front-page.php
Last active August 29, 2015 14:06
Show Gist options
  • Save freezvd/f914d0e3e6832f7ea46c to your computer and use it in GitHub Desktop.
Save freezvd/f914d0e3e6832f7ea46c to your computer and use it in GitHub Desktop.
<?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>';
}
<?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