Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- Template Name: Home Page
- *
- * @package WordPress
- * @subpackage Toolbox
- * @since Toolbox 0.1
- */
- get_header(); ?>
- <div id="primary" class="full-width">
- <div id="content" role="main">
- <?php $pageCheck = $post->ID; ?>
- <?php if ( get_post_meta($pageCheck, '728 x 90', true) ) :?>
- <div class="ad id-<?php echo $pageCheck; ?>">
- <?php echo get_post_meta($pageCheck, '728 x 90', true); ?>
- </div>
- <? endif ; ?>
- <div id="hero">
- <script type="text/javascript">
- jQuery(document).ready(function(){
- jQuery("#featured-slider").easySlider({
- hoverPause: true,
- auto: true,
- continuous: true,
- speed: 400,
- pause: 6000,
- numeric: true,
- numericId: 'controls'
- });
- });
- </script>
- <div id="featured-slider">
- <ul>
- <?php
- $sliderargs = array(
- 'posts_per_page' => 5, // get four posts for each section we want to show
- 'post_type' => array('recipe','la_foodie','nyc_foodie','mixology','chefs_table'));
- $my_query = new WP_Query($sliderargs); ?>
- <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
- <li>
- <div class="left"><?php $alt_tag = get_the_title($post->ID); ?>
- <?php if ( has_post_thumbnail() ) { ?>
- <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
- <?php the_post_thumbnail('featured-image', array('alt' => 'View the Recipe', 'title' => $alt_tag )); ?>
- </a>
- </div>
- <?php } ?>
- <div class="right">
- <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
- <p><?php new_excerpt(180); ?></p>
- <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">Read More ></a>
- </div>
- </li>
- <?php endwhile; ?>
- </ul>
- </div>
- </div>
- <?php
- global $post;
- $total_sections = 4; // the total number of sections that you want in your slider
- $args = array(
- 'posts_per_page' => $total_sections * 4, // get four posts for each section we want to show
- 'post_type' => array('post','recipe','la_foodie','nyc_foodie','mixology','chefs_table')
- );
- $carousel_query = new WP_Query($args);
- if ($carousel_query->have_posts()) {
- $slider = array();
- $section = array();
- while ($carousel_query->have_posts()) {
- $carousel_query->the_post();
- // Not sure what you actually want to put in the grid for each post...so edit here as you need to...
- $html = sprintf('<h2 class="entry-title"><a href="%1$s" title="%2$s">%2$s</a></h2><a href="%1$s" title="%2$s">%3$s</a>',
- get_permalink(), get_the_title(),get_the_post_thumbnail( $post->ID, 'thumbnail'));
- $section[] = $html;
- // for the third and sixth array slots, put in ad code
- // since our original WP_Query pulled randomly, then the actual ads that get pulled for
- // these slots will be...random!
- if( count($section) == 2 || count($section) == 5 ) {
- $fields = array('300 x 250 Bottom', '300 x 250 Top');
- $adcode = get_post_meta( $post->ID, $fields[array_rand($fields, 1 )], true );
- $section[] = $adcode;
- }
- // If we've got a group of 6....
- if( count($section) == 6 ) {
- shuffle($section); // We need to mix up the six so that the ads could be anywhere
- $slider[] = $section; // store the group in our slider list
- $section = array(); // and reset the section
- }
- }
- // This is belt and braces since you should have pulled exactly the
- // right amount of posts, but if you haven't then the while loop will
- // have bailed out before the group got added to the slider
- if( !empty($section) ) {
- shuffle($section); // We need to mix up the six so that the ads could be anywhere
- $slider[] = $section;
- }
- // By now you should have an array of size $total_sections, each with an array of 6 inside
- // So you can do you html loop
- $i = 1;
- echo '<ul id="slider">';
- foreach( $slider as $section ) {
- echo '<li id="section_'.$i.'"><ul>';
- foreach( $section as $box ) {
- echo '<li class="section_box">'.$box.'</li>';
- }
- echo '</ul></li>';
- $i++;
- }
- echo '</ul>';
- }
- ?>
- </div><!-- #content -->
- </div><!-- #primary -->
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement