How to add pagination in my custom template functions
-
I added a custom template named gallery.php which has functions to show youtube video and i called ‘posts_per_page’ => 10 BUT after 10 it is not showing pagination to view more videos, can you please tell me how can i add pagination in this..
<?php /** Template Name: gallery */ get_header(); ?> <style> /* some basic styling */ h1 {font-size:20px; line-height:95%;} #galvidcontainer { width:1243px; margin-left:50px; height:auto; float:left; clear:right; } galvidcontainer.clear { clear:both; } .galvidpre { width:325px; height:300px; float:left; margin:5px; background-color:#00A0DA; } .galvidprevid { width:325px; } .galvidpretext { width:280px; padding-top:2px; margin-top:2px; } #sidebar { float:left; width:150px; } #footer{ height: 100%; clear: both; bottom: 0; width: 100%; } </style> <div id="galvidcontainer"> <h1>Videos</h1> <?php /* Loop the stuff from the videos post type */ $args = array( 'post_type' => 'videos', 'posts_per_page' => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();?> <div class="galvidpre"> <div class="galvidprevid"> <?php /* Set variables and create if stament */ $videosite = get_post_meta($post->ID, 'Video Site', single); $videoid = get_post_meta($post->ID, "Video ID", single); if ($videosite == vimeo) { echo '<iframe src="https://player.vimeo.com/video/'.$videoid.'" width="325" height="190" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; } else if ($videosite == youtube) { echo '<iframe width="325" height="190" src="https://www.youtube.com/embed/'.$videoid.'" frameborder="0" allowfullscreen></iframe>'; } else { echo 'Please Select Video Site Via the CMS'; } ?> </div> <div class="galvidpretext"> <h1><?php the_title() ?></h1> <p> <?php /* this is just a limit on characters displayed */ $words = explode(" ",strip_tags(get_the_content())); $content = implode(" ",array_splice($words,0,20)); echo $content; ?> </p> </div> </div> <?php get_sidebar(); ?> <?php endwhile; ?> </div> <?php get_footer(); ?>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How to add pagination in my custom template functions’ is closed to new replies.