Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 5.03 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Using jQuery plugin in WordPress post loop
  2. <?php get_header(); ?>
  3. <div id="page-blocks">
  4.     <div id="pb-col">
  5.         <?php
  6.             if(is_category()) {
  7.                 $cat_title = single_cat_title('', false);
  8.                 echo "<div id="pb-breadcrumbs" class="tag-wrap">Viewing Category &raquo; <span>$cat_title</span></div>";
  9.             } else if (is_tag()) {
  10.                 $tag_title = single_cat_title('', false);
  11.                 echo "<div id="pb-breadcrumbs" class="tag-wrap">Viewing Tag &raquo; <span>$tag_title</span></div>";
  12.             } else if ((is_tax('hype_image_types')) && ($reg_pt_images)) {
  13.                  $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
  14.                 echo "<div id="pb-breadcrumbs" class="tag-wrap">Viewing Image Type &raquo; <span>$term->slug</span></div>";
  15.             } else if ((is_tax('hype_video_types')) && ($reg_pt_videos)) {
  16.                  $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
  17.                 echo "<div id="pb-breadcrumbs" class="tag-wrap">Viewing Video Type &raquo; <span>$term->slug</span></div>";
  18.             }
  19.         ?>
  20.         <?php      
  21.              if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  22.  
  23.                 <div class="pb-post-multiple">
  24.                     <!-- post -->
  25.                     <?php
  26.  
  27.                         $edit_attr = array(
  28.                             'alt' => $post->post_title,
  29.                             'title' => ''
  30.                             );
  31.  
  32.                         $post_thumb = get_post_meta($post->ID, 'image-thumb', true);
  33.                         if(empty($post_thumb)) {
  34.                             $post_thumb = get_the_post_thumbnail($post->ID,'hype-custom-image-thumb', $edit_attr);
  35.                         } else {
  36.                             $post_thumb = "<img src="$wud/$post_thumb" alt="" . $edit_attr['alt'] . "" class="" . $edit_attr['class'] . "" />";
  37.                         }                      
  38.                     ?>
  39.                     <?php if(!empty($post_thumb)) { ?>
  40.                         <div class="post-img-thumb">            
  41.                             <a href="<?php the_permalink(); ?>"><?php echo $post_thumb; ?></a>
  42.                         </div>                                                  
  43.                     <?php }?>
  44.                     <div class="post-desc-multiple">
  45.                         <h2 class="header-wrap"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  46.                         <?php
  47.  
  48.                             if(get_post_type()=='post'){
  49.                                 $the_date = get_the_time('l, F j, Y');
  50.                             }
  51.  
  52.                             $comment_count = get_comments_number();
  53.                             if($comment_count >= 1 && get_post_type()=='post') {
  54.                                 $comment_buffer = "&nbsp;&nbsp;&middot;&nbsp;&nbsp;";
  55.                             } else {
  56.                                 $comment_buffer = "";
  57.                             }
  58.  
  59.                             ?>
  60.                             <div class="post-date-multiple"><?php echo $the_date . $comment_buffer ?><a href="<?php the_permalink(); ?>#comments-block"><span><?php comments_number('', '1 Comment', '% Comments') ?></span></a></div>
  61.                             <?php
  62.                             $the_excerpt = strip_shortcodes(get_the_excerpt());
  63.                             echo $the_excerpt;
  64.                         ?>
  65.                         <div class="post-more hype-btn clearfix">
  66.                             <a href="<?php the_permalink(); ?>"><span>Read More &raquo;</span></a>
  67.                         </div>
  68.                     </div>
  69.                     <div class="clear"></div>
  70.                 </div>
  71.  
  72.         <?php endwhile; ?>
  73.             <!-- post navigation -->
  74.             <div class="post-nav">
  75.                 <div class="post-nav-left hype-btn"><?php previous_posts_link(); ?></div>
  76.                 <div class="post-nav-right hype-btn"><?php next_posts_link(); ?></div>              
  77.             </div>
  78.         <?php else: ?>
  79.             <!-- no posts found -->
  80.         <?php endif; ?>    
  81.     </div>
  82.         <?php get_sidebar(); ?>
  83. </div>
  84.  
  85. <?php get_footer(); ?>
  86.        
  87. $(function() {
  88.  
  89.     function scroll(direction) {
  90.  
  91.         var scroll, i,
  92.                 positions = [],
  93.                 here = $(window).scrollTop(),
  94.                 collection = $('#scroll');
  95.  
  96.         collection.each(function() {
  97.             positions.push(parseInt($(this).offset()['top'],10));
  98.         });
  99.  
  100.         for(i = 0; i < positions.length; i++) {
  101.             if (direction == 'next' && positions[i] > here) { scroll = collection.get(i); break; }
  102.             if (direction == 'prev' && i > 0 && positions[i] >= here) { scroll = collection.get(i-1); break; }
  103.         }
  104.  
  105.         if (scroll) {
  106.             $.scrollTo(scroll, {
  107.                 duration: 750      
  108.             });
  109.         }
  110.  
  111.         return false;
  112.     }
  113.  
  114.     $("#next,#prev").click(function() {        
  115.         return scroll($(this).attr('id'));        
  116.     });
  117.  
  118. });