• Ok so I have built a custom theme and realized I needed pagination. The site runs off of a custom post type as well as the default “Post” post-type.
    I’ve read this [ http://codex.wordpress.org/Function_Reference/paginate_links ] and have tried it every which way and the links don’t appear.

    I have also read through these forums and got some tips about globalizing $paged and putting it into the query etc and the pagination still doesnt show.

    My code is below – any help would be muchly appreciated.

    <?php
    	global $paged, $wp_query;
    	get_header('home');
    
    	$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
    
    	$awk_title = '';
    
    	$all_args = array(
    		'post_type' => 'awk_firstfruits',
    		'posts_per_page' => 2,
    		'paged' => get_query_var('paged'),
    	);
    
    	// array( 'awk_authors', 'awk_story', 'awk_resrouces',
    	// 'awk_firstfruits', 'awk_media', 'awk_calendar'
    
    	$featured_args = array(
    		'post_type' => array( 'awk_featured'),
    		'order' => 'ASC',
    		'posts_per_page' => -1
    	);
    
    	$authors_args = array(
    		'post_type' => 'awk_authors',
    		'posts_per_page' => 1
    	);
    
    	$story_args = array(
    		'post_type' => 'awk_story',
    		'posts_per_page' => 10
    	);
    
    	$resources_args = array(
    		'post_type' => 'awk_resource',
    		'posts_per_page' => 10
    	);
    
    	$media_args = array(
    		'post_type' => 'awk_media',
    		'posts_per_page' => 10
    	);
    
    	$calendar_args = array(
    		'post_type' => 'awk_calendar',
    		'posts_per_page' => 10
    	);
    
    	if ( is_front_page() || is_page('archive') ) {
    		$query = new WP_Query( $all_args );
    		$feat_query = new WP_Query( $featured_args );
    		$awk_title = 'One New Man Updates';
    
    	} elseif ( is_page('Out Story') ) {
    		$query = new WP_Query( $story_args );
    
    	} elseif ( is_page('store') ) {
    		$query = new WP_Query( $resources_args );
    		$awk_title = 'Resource Center';
    
    	} elseif ( is_page('donations') ) {
    		$query = new WP_Query('pagename=donations');
    		$awk_title = 'Donations';
    
    	} elseif ( is_page('authors') ) {
    		$query = new WP_Query('pagename=donations');
    		$awk_title = 'Author Bio';
    
    	} elseif ( is_page('first-nations-declarations') ) {
    		$query = new WP_Query('pagename=first-nations-declarations');
    		$awk_title = 'First Nations Declarations';
    
    	} elseif ( is_page('our-story') ) {
    		$query = new WP_Query('pagename=our-story');
    		$awk_title = 'Our Story';
    
    	} elseif ( is_page('our-roots') ) {
    		$query = new WP_Query('pagename=our-roots');
    		$awk_title = 'Our Story';
    
    	} elseif ( is_page('statement-of-faith') ) {
    		$query = new WP_Query('pagename=statement-of-faith');
    		$awk_title = 'Our Roots';
    	} elseif ( is_page('contact-us') ) {
    		$query = new WP_Query('pagename=contact-us');
    		$awk_title = 'Contact Us';
    	} elseif ( is_page('brochure') ) {
    		$query = new WP_Query('pagename=brochure');
    		$awk_title = 'Brochure';
    	} elseif ( is_page('site-map') ) {
    		$query = new WP_Query('pagename=site-map');
    		$awk_title = 'Brochure';
    	};
    ?>
    
    <?php if( is_home() ) : ?>
    <aside id="slider" class="gradient">
    	<div id="images">
    		<?php
    			if ( $feat_query->have_posts() ) : while ( $feat_query->have_posts() ) : $feat_query->the_post();
    		?>
    			<figure class="image">
    				<h3><a href="<?php echo $cfs->get('slide_link'); ?>"><?php the_title(); ?></a></h3>
    				<?php
    					if( has_post_thumbnail() ) :
    				?>
    					<a href="<?php echo $cfs->get('slide_link'); ?>">
    						<?php the_post_thumbnail('frontpage-slider'); ?>
    					</a>
    				<?php
    					endif;
    				?>
    			<figcaption>
    				<p>
    					<?php the_content('Read More…', false); ?>
    				</p>
    			</figcaption>
    		</figure>
    		<?php endwhile; endif; wp_reset_postdata(); wp_reset_query(); ?>
    	</div>
    </aside>
    <?php endif; ?>
    <header class="main-nav">
    	<?php wp_nav_menu( array( 'theme_location' => 'main-menu', 'container_class' => 'main-nav clearfix' ) ); ?>
    </header>
    
    <!-- INDEX TEMPLATE -->
    <section id="content">
    	<header>
    		<h1><?php echo $awk_title; ?></h1>
    	</header>
    	<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
    		enable_more();
    	?>
    		<article <?php post_class(); ?>>
    			<?php
    				if( has_post_thumbnail() ) : ?>
    					<figure class="thumb border">
    						<a href="<?php the_permalink(); ?>">
    							<?php the_post_thumbnail('frontpage'); ?>
    						</a>
    					</figure>
    					<div class="text-cont">
    						<h1 class="post-title">
    							<a href="<?php the_permalink(); ?>">
    								<?php the_title(); ?>
    							</a>
    						</h1>
    
    						<?php
    							the_content('Read More');
    						?>
    					</div>
    			<?php
    				else :
    					echo '<h1 class="post-title">';
    					echo the_title();
    					echo '</h1>';
    					the_content();
    				endif;
    			?>
    
    		</article>
    	<?php
    		endwhile;
    
                    $big = 999999999;
    
                    echo paginate_links( array(
    	        'base' => str_replace( $big, '%#%', get_pagenum_link($big) ),
    	        'current' => max( 1, get_query_var('paged') ),
    	        'total' => $wp_query->max_num_pages,
    	        'mid_size' => 5
    	    ) );
    
    		else:
    	?>
    		<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    	<?php endif; wp_reset_postdata(); wp_reset_query(); ?>
    </section>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Pagination Links not working from index in custom template’ is closed to new replies.