CustomPress Pagination

I have set up a couple of custom post types using CustomPress and am having problems with the pagination on the archive pages for those post types. Is there something I should be doing differently?

The pagination numbers show up but when I click page 2, it brings me to page 2 but still shows the latest instead of the next ones.

I have simply copied and pasted the archive template and made minor adjustments in the loop.

The normal blog archive pages work fine. It is only the custom post types.

Any help would be appreciated!

  • 3SixtyEvolve

    Hi Eric

    Greetings from the WMPU DEV Support Team!

    Thank you for your post and for being a member of our Community. Now let's tackle your problem :slight_smile:

    I have simply copied and pasted the archive template and made minor adjustments in the loop.

    It would be good to see what adjustments you've made - if I can see the code, that would be great. It might be something small on there that need to be adjusted. Once I have the code I can check with our Developers as well and we'll get you sorted in no time.

    Looking forward to your feedback.

    Glad to assist!

    GinaB

  • Eric G.

    Here is the original archive code:

    <div id="sidebar_layout">
    		<div class="sidebar_layout-inner">
    			<div class="grid-protection">
    
    				<?php themeblvd_fixed_sidebars( 'left' ); ?>
    
    				<!-- CONTENT (start) -->
    
    				<div id="content" role="main">
    					<div class="inner">
    						<?php themeblvd_content_top(); ?>
    						<?php if( $template_part == 'grid' || $template_part == 'archive_grid' ) : ?>
    
    							<!-- ARCHIVE POST GRID (start) -->
    
    							<div class="post_grid post_grid_paginated archive">
    								<div class="grid-protection">
    									<?php
    									$posts_per_page = get_option( 'posts_per_page' );
    									$counter = 1;
    									if ( have_posts() ) {
    										while ( have_posts() ) {
    											the_post();
    											if( $counter == 1 ) themeblvd_open_row();
    											get_template_part( 'content', $template_part );
    											if( $counter % $columns == 0 ) themeblvd_close_row();
    											if( $counter % $columns == 0 && $posts_per_page != $counter ) themeblvd_open_row();
    											$counter++;
    										}
    										if( ($counter-1) != $posts_per_page ) themeblvd_close_row();
    									} else {
    										echo '<p>'.themeblvd_get_local( 'archive_no_posts' ).'</p>';
    									}
    									?>
    								</div><!-- .grid-protection (end) -->
    								<?php themeblvd_pagination(); ?>
    							</div><!-- .post_grid (end) -->
    
    							<!-- ARCHIVE POST GRID (end) -->
    
    						<?php else : ?>
    
    							<!-- ARCHIVE POST LIST (start) -->
    
    							<div class="post_list post_list_paginated archive">
    								<?php if ( have_posts() ) : ?>
    									<?php while ( have_posts() ) : the_post(); ?>
    										<?php get_template_part( 'content', themeblvd_get_part( 'archive' ) ); ?>
    									<?php endwhile; ?>
    								<?php else : ?>
    									<p><?php echo themeblvd_get_local( 'archive_no_posts' ); ?></p>
    								<?php endif; ?>
    								<?php themeblvd_pagination(); ?>
    							</div><!-- .blogroll (end) -->
    
    							<!-- ARCHIVE POST LIST (end) -->
    
    						<?php endif; ?>
    
    					</div><!-- .inner (end) -->
    				</div><!-- #content (end) -->
    
    				<!-- CONTENT (end) -->		
    
    				<?php themeblvd_fixed_sidebars( 'right' ); ?>
    
    			</div><!-- .grid-protection (end) -->
    		</div><!-- .sidebar_layout-inner (end) -->
    	</div><!-- .sidebar-layout-wrapper (end) -->
  • Eric G.

    Here is the page that is not acting as it should.

    <div id="sidebar_layout">
    		<div class="sidebar_layout-inner">
    			<div class="grid-protection">
    
    				<?php themeblvd_fixed_sidebars( 'left' ); ?>
    
    				<!-- CONTENT (start) -->
    
    				<div id="content" role="main">
    					<div class="inner">
    						<?php themeblvd_content_top(); ?>
    						<?php if( $template_part == 'grid' || $template_part == 'archive_grid' ) : ?>
    
    							<!-- ARCHIVE POST GRID (start) -->
    
    							<div class="post_grid post_grid_paginated archive">
    								<div class="grid-protection">
    									<?php
    									$posts_per_page = get_option( 'posts_per_page' );
    									$counter = 1;
    									if ( have_posts() ) {
    										while ( have_posts() ) {
    											the_post();
    											if( $counter == 1 ) themeblvd_open_row();
    											get_template_part( 'content', $template_part );
    											if( $counter % $columns == 0 ) themeblvd_close_row();
    											if( $counter % $columns == 0 && $posts_per_page != $counter ) themeblvd_open_row();
    											$counter++;
    										}
    										if( ($counter-1) != $posts_per_page ) themeblvd_close_row();
    									} else {
    										echo '<p>'.themeblvd_get_local( 'archive_no_posts' ).'</p>';
    									}
    									?>
    								</div><!-- .grid-protection (end) -->
    								<?php themeblvd_pagination(); ?>
    							</div><!-- .post_grid (end) -->
    
    							<!-- ARCHIVE POST GRID (end) -->
    
    						<?php else : ?>
    
    							<!-- ARCHIVE POST LIST (start) -->
    
    							<div class="post_list post_list_paginated archive">
    
    						<h2 align="center"><a href="http://cymhub.com/catholic-youth-ministry-speakers/">Catholic Youth Ministry Speakers</a></h2>
    
    	<div align="center">	<strong>Information in this directory is submitted by the speakers.</strong> <br />You can filter by topic or area of interest by clicking on them in a speaker profile.<br/>
    
    	</div>
    
    							<hr />
    
    								<?php if ( have_posts() ) : ?>
    									<?php while ( have_posts() ) : the_post(); ?>
    
    												<!-- page-title -->
    
    <?php $customfield_name = get_post_meta($post->ID, 'ct_Listing_Le_text_2169', true);
    if ($customfield_name == '1') { ?>
    <div id="speakerfull">
    <?php } else if ($customfield_name == '2') { ?>
    <div id="speakerfull2">
    <?php } else if ($customfield_name == '3') { ?>
    <div id="speakerfull3">
    <?php } else { ?>
    <div id="speakerfull">
    <?php } ?>												
    
    <div id="speakerleft">	<?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?>
    
    <?php $customfield_name = get_post_meta($post->ID, 'ct_Listing_Le_text_2169', true);
    if ($customfield_name == '2') { ?>
    <div align="center"><div class="fb-like" data-href="<?php echo get_post_meta( $post->ID, 'ct_Facebook_P_text_13c4', true ); ?>" data-send="false" data-layout="button_count" data-width="" data-show-faces="false"></div><br/>
    <a href="<?php echo get_post_meta( $post->ID, 'ct_Twitter_Pr_text_3b2d', true ); ?>" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @marybielski</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
    </div>
    <?php } else if ($customfield_name == '3') { ?>
    <div class="fb-like" data-href="<?php echo get_post_meta( $post->ID, 'ct_Facebook_P_text_13c4', true ); ?>" data-send="false" data-layout="button_count" data-width="150" data-show-faces="false"></div>
    <?php } else { ?>
    <?php } ?>		
    
    </div>
    
    		<div id="speakermid">
    				<h3><strong><?php the_title(); ?></strong></h3>				
    
    <?php echo get_the_term_list( $post->ID, 'ministry', '<strong>Ministries:</strong><br/> ', ', ', '' ); ?> <br/><br/>
    
    <?php echo get_the_term_list( $post->ID, 'topics', '<strong>Areas of Interest:</strong><br/> ', ', ', '' ); ?>
    		</div>
    
    <div id="speakerright">
    
    <div id="votebox"><?php wdpv_vote(); ?></div>
    <div id="votebox1"><strong><div align="right">Thumbs Up If You Like!</strong></div></div>
    
    <div id="clear"></div><br/>
    
    <div align="center"><strong> Connect w/ This Speaker </strong></div>
    
    <div id="clearboth">
    <div align="center">
    <!-- FACEBOOK -->
    <?php $customfield_name = get_post_meta($post->ID, 'ct_Facebook_P_text_13c4', true);
    if ($customfield_name == '') { ?>
    <?php } else { ?>
    <a href="<?php echo get_post_meta( $post->ID, 'ct_Facebook_P_text_13c4', true ); ?>" target="_blank"><img src="http://www.cymhub.com/images/socialicons/facebook.png" /></a>
    <?php } ?>
    <!-- Twitter -->
    <?php $customfield_name = get_post_meta($post->ID, 'ct_Twitter_Pr_text_3b2d', true);
    if ($customfield_name == '') { ?>
    <?php } else { ?>
    <a href="<?php echo get_post_meta( $post->ID, 'ct_Twitter_Pr_text_3b2d', true ); ?>" target="_blank"><img src="http://www.cymhub.com/images/socialicons/twitter.png" /></a>
    <?php } ?>
    <!-- YouTube -->
    <?php $customfield_name = get_post_meta($post->ID, 'ct_Youtube_Ch_text_f856', true);
    if ($customfield_name == '') { ?>
    <?php } else { ?>
    <a href="<?php echo get_post_meta( $post->ID, 'ct_Youtube_Ch_text_f856', true ); ?>" target="_blank"><img src="http://www.cymhub.com/images/socialicons/youtube.png" /></a>
    <?php } ?>	
    
    				<?php $customfield_name = get_post_meta($post->ID, 'ct_Web_Site_text_cdd6', true);
    if ($customfield_name == '') { ?>
    <?php } else { ?>
    <br/><br/><div align="center"><a href="<?php echo get_post_meta( $post->ID, 'ct_Web_Site_text_cdd6', true ); ?>" target="_blank">Visit Website</a></div>
    <?php } ?>	
    
    </div>
    
    </div>
    
    </div>
    </div>		
    
    					<div id="clear"></div>
    
    				<!-- /page-title -->
    									<?php endwhile; ?>
    								<?php else : ?>
    									<p><?php echo themeblvd_get_local( 'archive_no_posts' ); ?></p>
    								<?php endif; ?>
    
    								<br/>
    									<div align="center">Are you a Catholic Youth Ministry Speaker? <a href="http://cymhub.com/speaker-request/" target="_blank">Click Here</a> for information on how to get listed!	<br/><br/>
    
    									  <a href="http://cymhub.com/speaker-feature-levels/" target="_blank">How Do I Get Featured?/About The Feature Levels</a> </div>
    
    								    <?php themeblvd_pagination(); ?>
    		  </div><!-- .blogroll (end) -->
    
    							<!-- ARCHIVE POST LIST (end) -->
    
    						<?php endif; ?>
    
    					</div><!-- .inner (end) -->
    				</div><!-- #content (end) -->
    
    				<!-- CONTENT (end) -->		
    
    				<?php themeblvd_fixed_sidebars( 'right' ); ?>
    
    			</div><!-- .grid-protection (end) -->
    		</div><!-- .sidebar_layout-inner (end) -->
    	</div><!-- .sidebar-layout-wrapper (end) -->
  • 3SixtyEvolve

    Hi Eric

    Wow, that's a lot of code there :slight_smile:

    Apologies for not responding soon.

    I've requested the Developer to provide feedback and suggestions on this matter. I will make sure that he respond at the earliest.

    I assure you that your posts are important to us and we will try to resolve this matter for you.

    Have a good day.

    Gina

    PS As a general rule, we request users to only paste 10 lines of code on here. Anything longer than that, we recommend they use pastebin.com and provide a link on the thread. Our bbPress Code Plugin doesn't handle much more than that very effectively.

  • Arnold

    Kind of guessing. There is a global wordpress variable $paged which keeps track of which page you are currently on. It's usually read from the $_POST information. I'm not familiar with the themeblvd code so I don't know how it handles pagination.

    I have a suspicion the the get_template_part in the orginal but not in the modifed may be doing some counting for pagination.

    <?php get_template_part( 'content', themeblvd_get_part( 'archive' ) ); ?>

    You'd have to inspect the theme code to tell.

  • Arnold

    I'm familiar with that problem. For all other pages the variable name is the global $paged. If the page is the Front Page of a statis page setup for some reason it changes to $page (no d).

    Is the page you're having problems with the Front page in a static setup?

    If so and since he's asking those questions he probably is using standard pagination just wrapped in his own commands. The fix for the Front page problem is pretty simple.

    global $paged;
    
    //get page number for pagination
    if ( get_query_var('paged') ) {
      $paged = get_query_var('paged'); //Usually paged
    } elseif ( get_query_var('page') ) { //But if front page it's page
      $paged = get_query_var('page');
    } else {
      $paged = 1;
    }

    You can try putting that at the top of your page

  • Eric G.

    @Arnold

    Thank you so much for your attention to this. I am not working with the front page on this one.

    It is a CustomPress archive page. So I have the page archive-speakers.php using the plugin and I have the slug set so the custom posts show up here: http://cymhub.com/catholic-youth-ministry-speakers/

    I currently have my max posts set to 15 until the problem is fixed so the pagination is not currently being used.

  • Arnold

    HI Greg,

    I got it working. I'm not sure what you did to get you template to display but here's how I did it.

    I took you archive-speakers.php template and gave it a Template Name tag at the top.

    /* Template Name: Speakers Archive */

    Name doesn't matter just so long as you recognize it. Then I added the post query for the custom type "speakers"

    <?php
    global $paged;
    $posts_per_page = get_option( 'posts_per_page' );
    query_posts( array( 'paged' => $paged, 'post_type' => 'speakers', 'post_status' => 'publish', 'posts_per_page' => 10 ));
    ?>

    I used a 10 for the posts per page put you could use the option above $posts_per_page if it's defined on your system. Saved the Template.

    Then I made a new Page and instead of the Default template I selected your custom template. Now that it's named it will show up automatically in the list. Gave the page the title "Catholic Youth Ministry Speakers" which gives the permalinnk "catholic-youth-ministry-speakers/". Saved the blank page. Removed your old entry from the Menu and put this one in it's place. Now it works.

  • Eric G.

    @Arnold

    Absolutely the best support I have received here ever. You are awesome!

    I will have to spend some time picking apart what you did as it seems like a much different approach than I am used to. I typically just check out the template hierarchy and start there instead of queries as I just have had a hard time perfecting my query magic.

    Thanks so much though, a great temporary solution and your instructions on it was done will be most helpful as I train myself to do things this way.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.