- Using jQuery plugin in WordPress post loop
- <?php get_header(); ?>
- <div id="page-blocks">
- <div id="pb-col">
- <?php
- if(is_category()) {
- $cat_title = single_cat_title('', false);
- echo "<div id="pb-breadcrumbs" class="tag-wrap">Viewing Category » <span>$cat_title</span></div>";
- } else if (is_tag()) {
- $tag_title = single_cat_title('', false);
- echo "<div id="pb-breadcrumbs" class="tag-wrap">Viewing Tag » <span>$tag_title</span></div>";
- } else if ((is_tax('hype_image_types')) && ($reg_pt_images)) {
- $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
- echo "<div id="pb-breadcrumbs" class="tag-wrap">Viewing Image Type » <span>$term->slug</span></div>";
- } else if ((is_tax('hype_video_types')) && ($reg_pt_videos)) {
- $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
- echo "<div id="pb-breadcrumbs" class="tag-wrap">Viewing Video Type » <span>$term->slug</span></div>";
- }
- ?>
- <?php
- if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
- <div class="pb-post-multiple">
- <!-- post -->
- <?php
- $edit_attr = array(
- 'alt' => $post->post_title,
- 'title' => ''
- );
- $post_thumb = get_post_meta($post->ID, 'image-thumb', true);
- if(empty($post_thumb)) {
- $post_thumb = get_the_post_thumbnail($post->ID,'hype-custom-image-thumb', $edit_attr);
- } else {
- $post_thumb = "<img src="$wud/$post_thumb" alt="" . $edit_attr['alt'] . "" class="" . $edit_attr['class'] . "" />";
- }
- ?>
- <?php if(!empty($post_thumb)) { ?>
- <div class="post-img-thumb">
- <a href="<?php the_permalink(); ?>"><?php echo $post_thumb; ?></a>
- </div>
- <?php }?>
- <div class="post-desc-multiple">
- <h2 class="header-wrap"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
- <?php
- if(get_post_type()=='post'){
- $the_date = get_the_time('l, F j, Y');
- }
- $comment_count = get_comments_number();
- if($comment_count >= 1 && get_post_type()=='post') {
- $comment_buffer = " · ";
- } else {
- $comment_buffer = "";
- }
- ?>
- <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>
- <?php
- $the_excerpt = strip_shortcodes(get_the_excerpt());
- echo $the_excerpt;
- ?>
- <div class="post-more hype-btn clearfix">
- <a href="<?php the_permalink(); ?>"><span>Read More »</span></a>
- </div>
- </div>
- <div class="clear"></div>
- </div>
- <?php endwhile; ?>
- <!-- post navigation -->
- <div class="post-nav">
- <div class="post-nav-left hype-btn"><?php previous_posts_link(); ?></div>
- <div class="post-nav-right hype-btn"><?php next_posts_link(); ?></div>
- </div>
- <?php else: ?>
- <!-- no posts found -->
- <?php endif; ?>
- </div>
- <?php get_sidebar(); ?>
- </div>
- <?php get_footer(); ?>
- $(function() {
- function scroll(direction) {
- var scroll, i,
- positions = [],
- here = $(window).scrollTop(),
- collection = $('#scroll');
- collection.each(function() {
- positions.push(parseInt($(this).offset()['top'],10));
- });
- for(i = 0; i < positions.length; i++) {
- if (direction == 'next' && positions[i] > here) { scroll = collection.get(i); break; }
- if (direction == 'prev' && i > 0 && positions[i] >= here) { scroll = collection.get(i-1); break; }
- }
- if (scroll) {
- $.scrollTo(scroll, {
- duration: 750
- });
- }
- return false;
- }
- $("#next,#prev").click(function() {
- return scroll($(this).attr('id'));
- });
- });