• Hi guys, I’m not that expert in wordpress codings. can you help me how to add pagination in my page template. I already added a code that will show all my posts in my custom page template. The thing is, i have more than 20 post and i want to show 5 post per page in that template. I can’t add the pagination. i already tried other plugin but it did’nt work. heres my custom page template and sorry for my codings. I’m still newbie in this.

    <?php /* Template Name: Portfolio */ ?>
    
    <?php get_header(); ?>
    
    <div id="primary" class="content-area">
    	<main id="main" class="site-main" role="main">
    		<!-- portfolio -->
    				<div class="portfolio">
    					<header class="title-box">
    						<hgroup>
    							<h1 class="text-shadow">Welcome to our portfolio</h1>
    							<h2> View our featured work & prepare to be wowed!</h2>
    						</hgroup>
    						<!-- subnav -->
    						<nav class="subnav">
    							<ul>
    								<li><a href="ecommerce"><span class="lowercase">e</span>commerce</a></li>
    								<li><a href="creative">Creative</a></li>
    								<li class="everything"><a href="everything" class="active">everything</a></li>
    								<li><a href="corporate">corporate</a></li>
    								<li><a href="branding">Branding</a></li>
    							</ul>
    						</nav>
    					</header>
    					<img src="https://www.tusswanydesign.com/images/img-port-plane.png" height="200" width="158" alt="Tusswany Designs, Tusswany, Tusswany design, web design, web designer, web designs philippines, website maker, web design, website developer, web developer" class="portfolio-plane">
    					<img src="https://www.tusswanydesign.com/images/img-glider.png" height="127" width="99" alt="Tusswany Designs, Tusswany, Tusswany design, web design, web designer, web designs philippines, website maker, web design, website developer, web developer" class="portfolio-glider">
    					<!-- portfolio-list -->
    					<ul class="portfolio-list">
    			<?php
    
    										$args = array( 'posts_per_page' => 15, 'order'=> 'DESC', 'orderby' => 'date' );
    
    										$myposts = get_posts( $args );
    										foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
    						<li class="<?php $categories = get_the_category();
    												$category_names = array();
    												foreach ($categories as $category)
    												{
    												    $category_names[] = $category->cat_name;
    												}
    												echo implode(' ', $category_names); ?>">
    							<a href="<?php echo get_post_meta($post->ID, 'url-link', true); ?>"><img src="<?php
    																								//Get the Thumbnail URL
    																								$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 232,226 ), false, '' );
    																								echo $src[0];
    		?>" height="232" width="226" alt="Tusswany Designs, Tusswany, Tusswany design, web design, web designer, web designs philippines, website maker, web design, website developer, web developer">
    										<div class="hover-mask">
    											<div class="holder">
    												<div class="top-slide">
    													<h3><?php the_title(); ?></h3>
    													<?php the_content(); ?>
    												</div>
    												<span class="view">View</span>
    											</div>
    										</div>
    									</a>
    						</li>
    
    										<?php endforeach;
    										wp_reset_postdata();?>
    
    					</ul>
    
    				</div>
    
    	</main><!-- .site-main -->
    
    	<?php get_sidebar( 'content-bottom' ); ?>
    
    </div><!-- .content-area -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Problem to add pagination in custom page template’ is closed to new replies.