Sergei-78 Posted February 17, 2015 Share Posted February 17, 2015 I am using the Starkers Wordpress theme as a foundation for my website and I am having difficulty getting my category.php to paginate posts properly. I am trying to display 10 posts per each page. When I click the 2,3,4,... post pagination button, it open the page but does not actually load new posts. Here is the code I have in my category.php file. Please could you help me to fix this issue? Please let me know if you need me to clarify anything further. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $cat = get_query_var('cat'); $catinfo = get_the_category($cat); ?> <div class="row"> <div class="large-8 small-12 columns"> <h2 class="category-header"><?php echo single_cat_title( '', false );?></h2> <?php if(1 == $paged) { //check if is page one and display main headlines and subcategories?> <?php //get category headline $cat = get_query_var('cat'); $category_headline = ae_get_category_headline($cat); if ($category_headline) { ?> <div class="category-headline"> <?php foreach($category_headline as $post) : setup_postdata($post); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <h3><?php the_title(); ?></h3></a> <?php the_content('Read more...'); ?> <ul class="inline-list main-headline-social"> <li><?php comments_popup_link('Leave a Comment', 'View Comments (1)', 'View Comments (%)'); ?></li> <li class="addthis_toolbox addthis_pill_combo_style"><a addthis:url="<?php the_permalink(); ?>" class="addthis_button_facebook_like"></a><a addthis:url="<?php the_permalink(); ?>" class="addthis_button_tweet"></a><a addthis:url="<?php the_permalink(); ?>" class="addthis_button_compact"></a></li> </ul> <?php endforeach; ?> <?php wp_reset_postdata(); ?> </div> <?php } ?> <div class="all-category-posts"> <h4 class="title">All news in <?php echo single_cat_title( '', false );?></h4> <?php global $post; $args = array( 'posts_per_page' => 10, 'post_type' => 'post', 'cat' => $cat, 'offset' => 1, 'orderby' => 'post_date', 'order' => 'desc', 'post_status' => 'publish', 'suppress_filters' => true, 'paged' => $paged, ); $allposts = get_posts($args); foreach ($allposts as $post) : setup_postdata($post); ?> <article> <header> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail(array(80,80), array('class' => 'alignleft')); ?></a> <p class="date"><?php the_time(get_option('date_format')); ?></p> <hr class="rule" /> <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a> </header> <?php the_excerpt(); ?> </article> <?php endforeach; ?> </div> <?php if ($cat == 9) { ?> <div class="whats-hot-videos"> <a href="<?php home_url(); ?>/videos/" title="Hot Videos"><h4 class="title">Hot Videos!</h4></a> <?php global $post; $args = array( 'ae-video-categories' => 'hot-videos', 'number_of_posts' => 4, 'post_type' => 'ae-videos', 'orderby' => 'post_date', 'order' => 'desc', 'post_status' => 'publish', 'suppress_filters' => true, ); $videos = get_posts($args); ?> <ul class="large-block-grid-4 small-block-grid-2"> <?php foreach ($videos as $post) : setup_postdata($post); ?> <?php $videoid = get_post_meta($post->ID, 'videoid', true); ?> <li> <a href="http://www.youtube.com/watch?v=<?php echo $videoid; ?>" rel="wp-video-lightbox" title="<?php the_title();?>"> <?php the_post_thumbnail(); ?> <h6><?php the_title(); ?></h6> </a> </li> <?php endforeach; ?> </ul> <div class="all-videos-link"><a href="<?php home_url(); ?>/videos/" title="All Videos">...More videos</a></div> </div> <?php } ?> <ul class="large-block-grid-2 small-block-grid-2 sub-categories"> <?php $args = array ( 'parent' => $cat, 'type' => 'post', 'hide_empty' => 1, ); $subcategories = get_categories($args); foreach ($subcategories as $category) { ?> <li> <div class="sub-category-headlines <?php echo $category->slug; ?>-subcategory"> <a href="<?php home_url(); ?>/category/<?php echo $category->slug; ?><?php echo "/"; ?>" title="<?php echo $category->name; ?>"><h4 class="title"><?php echo $category->name; ?></h3> <?php $subcategory_posts = ae_get_categoryposts($category->slug, 2); ?> <ul> <?php foreach ($subcategory_posts as $post) : setup_postdata($post); ?> <li class="subcategory-headline"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php the_post_thumbnail(array(150,100), array('class' => 'alignleft')); ?> <h3><small><?php the_title(); ?></small></h3> </a> </li> <?php endforeach; ?> </ul> </div> </li> <?php } ?> <?php } //end check if is page one?> </ul> <?php if(function_exists('wp_paginate')) { wp_paginate(); } ?> </div> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.