Skip to content

Instantly share code, notes, and snippets.

@korymath
Created November 20, 2013 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korymath/7572805 to your computer and use it in GitHub Desktop.
Save korymath/7572805 to your computer and use it in GitHub Desktop.
Videos Pagination Custom Post Type
<?php
/*
Template Name: Videos
*/
get_template_part( 'header' ); ?>
<div class="container">
<div class="header">
<a href="<?php bloginfo('url'); ?>"><div class="logo"></div></a>
<!-- end .header --></div>
<div class="content blog-content-item">
<?php get_template_part( 'sidebar' ); ?>
<div class="mainContent blog-content">
<img class="blog-banner" src="<?php bloginfo('template_directory'); ?>/images/videosBanner.png" />
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=41&posts_per_page=5&paged=' .$paged);
?>
<?php
if (have_posts()) :
$post = $posts[0];
$c=0;
while (have_posts()) : the_post();
$c++;
if($c == 1 && $paged == 1) :?>
<div class="video-row feature <?php echo $paged; ?>">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="video-embed">
<object width="500" height="330" data="http://www.youtube.com/v/<?php echo(types_render_field('youtube-video-id',array('raw'=>true))); ?>" type="application/x-shockwave-flash"><param name="src" value="http://www.youtube.com/v/<?php echo(types_render_field('youtube-video-id',array('raw'=>true))); ?>" /></object>
</div>
<?php the_excerpt(); ?>
</div>
<?php else :?>
<div class="video-row">
<div class="small-video-embed">
<object width="200" height="134" data="http://www.youtube.com/v/<?php echo(types_render_field('youtube-video-id',array('raw'=>true))); ?>" type="application/x-shockwave-flash"><param name="src" value="http://www.youtube.com/v/<?php echo(types_render_field('youtube-video-id',array('raw'=>true))); ?>" /></object>
</div>
<h2 class="video-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php echo excerpt(20); ?>
</div>
<?php
endif;
endwhile; ?>
<div class="pagination">
<div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
</div>
<?php endif; ?>
<?php wp_reset_query(); ?>
</div>
<?php get_template_part( 'sidebar-2' ); ?>
<br class="clearfloat" />
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment