Advertisement
marjwyatt

WSK Special Archive - Cooking Tips

Oct 19th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.87 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Template Name: Cooking Tips
  4.  */
  5. //Ref link: http://codex.wordpress.org/Function_Reference/have_posts
  6. //Pastebin link: http://pastebin.com/mkvhYwXU
  7. remove_action( 'genesis_post_title','genesis_do_post_title' ); // Removes post title
  8. remove_action( 'genesis_loop', 'genesis_do_loop' );
  9. add_action( 'genesis_loop', 'cooking_tips_archives' );
  10. ?>
  11.  
  12. <?php
  13. function cooking_tips_post_image() {
  14.  
  15.     if ( ! is_singular() && genesis_get_option( 'content_archive_thumbnail' ) ) {
  16.         $img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'alignleft post-image' ) ) );
  17.         printf( '<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute( 'echo=0' ), $img );
  18.     }
  19.  
  20. }
  21.  
  22. function cooking_tips_archives() {
  23. query_posts( array ( 'category_name' => 'cooking-tips', 'posts_per_page' => '-1' ) );
  24.  
  25. if (have_posts()) :
  26.     $i=0; // counter
  27.     while (have_posts()) : the_post(); ?>
  28.     <?php if ($i <= 2) { ?>
  29.         <div class="post type-post hentry">
  30.             <h2 class="entry-title"><a href="<?php echo get_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  31.             <div class="entry-content">
  32.                 <?php cooking_tips_post_image(); ?>
  33.                 <?php the_excerpt(); ?>
  34.                 <a class="more-link" href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>" >Read more...</a>
  35.             </div><!-- .entry-content -->
  36.         </div><!-- .post -->
  37.         <?php }; ?>
  38.         <?php if ($i == 3) { ?>
  39.             <div id="post type-post hentry">
  40.                 <h2 class="entry-title"><a href="<?php echo get_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  41.                 <?php cooking_tips_post_image(); ?>
  42.                 <div id="accordion-archive">
  43.                     <?php $shrt_cd = "[accordion title='More Cooking Tips from A Well-Seasoned Kitchen']";
  44.                         $query = new WP_Query( array ( 'category_name' => 'cooking-tips', 'offset' => '3' ) );
  45.                         $shrt_cd .= '<ul class="accordion-archive-list">';
  46.                     while (have_posts()) : the_post();
  47.                         $shrt_cd .= '<li><a href="'.get_permalink().'">';
  48.                         $shrt_cd .= get_the_title();
  49.                         $shrt_cd .= '</a></li>';
  50.                     endwhile;
  51.                     $shrt_cd .= '</ul>';
  52.                     $shrt_cd .= "[/accordion]";
  53.                     echo do_shortcode( $shrt_cd );
  54.                     wp_reset_query();
  55.                     ?>
  56.                 </div><!-- .entry-content -->
  57.             </div><!-- accordion-archive -->
  58.             <?php return $wp_query->current_post + 1 < $wp_query->post_count;?>
  59.         <?php }; ?>
  60.     <?php $i++; ?>
  61.     <?php endwhile; ?>
  62. <?php endif; ?>
  63.  
  64. <?php
  65. }
  66. genesis();
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement