-
-
Save onishiweb/4077671 to your computer and use it in GitHub Desktop.
Slide Loop
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
<?php | |
/* | |
Template Name: Homepage | |
*/ | |
$blog = new WP_Query('category_name=articles&posts_per_page=1'); | |
// $featured_products = new WP_Query('category_name=featured&posts_per_page=10'); | |
// Change to: | |
$featured_products = get_posts('category_name=featured&posts_per_page=10'); | |
?> | |
<?php get_header(); ?> | |
<div id="main" class="t1-t4 d1-d6"> | |
<section class="products m-padin t-padin d-padinfull clearfix"> | |
<h1>Featured Products</h1> | |
<div class="flexslider"> | |
<ul class="slides"> | |
<?php | |
// while($featured_products->have_posts()) : $featured_products->the_post(); | |
// Change to: | |
for ( $i=0; i<count($featured_products); $i++): | |
?> | |
<li> | |
<?php | |
// Call the post here... | |
$featured_products[$i]->the_post(); ?> | |
<!-- Not sure where $i is coming from in your original but likely that the $i var from the loop will mess this up --> | |
<article class="<?php echo $i == 2 ? "m-all t1-t2 d1-d3" : "m-all t3-t4 d4-d6"; ?>"> | |
<div class="image"> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > | |
<?php the_post_thumbnail('thumbnail'); ?> | |
</a> | |
</div> | |
<div> | |
<?php | |
$category = get_the_category(); | |
$category = first_top_level_category($category); | |
$catlink = get_category_link($category); | |
if ($category) { | |
echo '<a href="' . $catlink . '" class="genre" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> '; | |
} | |
?> | |
<h1><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_title(); ?></a></h1> | |
</div> | |
</article> | |
<?php | |
// Increment $i the counter | |
$i++; | |
$featured_products[$i]->the_post(); | |
?> | |
<!-- Not sure where $i is coming from in your original but likely that the $i var from the loop will mess this up --> | |
<article class="<?php echo $i == 2 ? "m-all t1-t2 d1-d3" : "m-all t3-t4 d4-d6"; ?>"> | |
<div class="image"> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > | |
<?php the_post_thumbnail('thumbnail'); ?> | |
</a> | |
</div> | |
<div> | |
<?php | |
$category = get_the_category(); | |
$category = first_top_level_category($category); | |
$catlink = get_category_link($category); | |
if ($category) { | |
echo '<a href="' . $catlink . '" class="genre" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> '; | |
} | |
?> | |
<h1><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_title(); ?></a></h1> | |
</div> | |
</article> | |
</li> | |
<?php | |
// endwhile; | |
// Change to: | |
endfor; | |
?> | |
</ul> | |
</div><!--END OF FLEXSLIDER--> | |
<footer class="clearfix"> | |
<a href="/featured" class="more">View more featured products</a> | |
</footer> | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment