Skip to content

Instantly share code, notes, and snippets.

@seandogg
Created October 15, 2015 18:08
Show Gist options
  • Save seandogg/671236fc0babe50969f5 to your computer and use it in GitHub Desktop.
Save seandogg/671236fc0babe50969f5 to your computer and use it in GitHub Desktop.
<?php
/**
* Template Name: Home Page
* Description: Loads some custom code for the homepage.
* @package Blink
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php //Slides loop
$args=array(
'post_type' => 'homepage-slides', //this is your cpt name
'post_status' => 'publish',
'posts_per_page' => -1, //this is the max number of slides
'orderby' => 'menu_order',
'order' => 'ASC'
);
$slide_query = new WP_Query($args);
if ($slide_query->have_posts()) :
echo '<ul class="bxslider">';
while ($slide_query->have_posts()) : $slide_query->the_post();
echo '<li><a href="' . get_field(slide_url) . '">';
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
echo '</a> <a href="' . get_field(slide_url) . '"><h1>';
echo get_the_title();
echo '</h1></a>';
echo '<a href="' . get_field(slide_url) . '"><button class="ghost">Learn More</button></a>';
echo '</li>';
endwhile; wp_reset_query();
echo '</ul>';
endif; ?>
<?php //Posts Loop
$args=array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => get_option( 'posts_per_page' ),
'orderby' => 'menu_order',
'order' => 'ASC'
);
$blog_query = new WP_Query($args);
if ($blog_query->have_posts()) :
while ($blog_query->have_posts()) : $blog_query->the_post();
get_template_part( 'partials/content', get_post_format() );
endwhile;
endif;
wp_reset_query(); ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_footer(); ?>
<script>
$(document).ready(function(){
$('.bxslider').bxSlider({
mode: 'fade',
captions: true,
auto: true,
controls: false
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment