Pagination broken in Custom Press

I am using Custom Press to create three custom post types: townships, cemeteries and churches. At the moment, I am working just with townships. Everything is working fine except for the archive page. I have set the custom slug to be archives-townships, so if you were to go to http://acgs.selfip.org/archives-townships, the page loads fine. However, at the bottom where the pagination is, if you click on 2 for the next page, you will get a 404.

This only seems to be a problem with the custom post type. If you click on any of the categories (President's Message, for instance), pagination works fine -- using the same basic template for both! What am I doing wrong or is this a known issue? I'm tearing my hair out!!

Thanks!

  • Adam Czajczyk

    Hello @HeatherFeuer,

    I hope you're well today and thank you for your question!

    Could you please go to your "Settings -> Permalinks" page in your dashboard and then:

    - switch permalinks setting to "Default"
    - save settings
    - switch back to as they are currently
    - save settings

    This often helps to fix this issue. In case it didn't, could you please share the code of your archives template with me? You should be able to add it to the post as a code, as an attached .txt file or as a link to e.g. pastebin.

    Best regards,
    Adam

  • HeatherFeuer

    Hi Adam,

    Thank you for the quick response. I tried the permalink switcheroo and that didn't work. Here is the code for the archive-townships.php template:

    <?php
    /**
     * The template for displaying archive pages.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package Quest
     */
    
    get_header();
    $layout = quest_get_mod( 'layout_archive_style' ); ?>
    <!-- This is the archive template -->
    <?php get_template_part( 'partials/content', $layout ); ?>
    
    <?php get_footer(); ?>

    The code for the partials/content is as follows:

    <?php $view = quest_get_view(); ?>
    
    <div id="content">
    	<?php quest_title_bar( $view ); ?>
    
    	<div class="quest-row site-content">
    		<div class="<?php echo apply_filters( 'quest_content_container_cls', 'container' ); ?>">
    			<div class="row">
    
    				<?php quest_try_sidebar( $view, 'left' ); ?>
    
    				<div id="primary" class="content-area <?php quest_main_cls(); ?>">
    					<main id="main" class="site-main" role="main">
    
    						<?php if ( have_posts() ) : ?>
    
    							<?php /* Start the Loop */ ?>
    							<?php while ( have_posts() ) : the_post(); ?>
    
    							<article <?php post_class( 'post-half clearfix' ); ?> id="post-<?php the_ID(); ?>">
    								<?php get_template_part( 'partials/content', 'sticky' ); ?>
    								<h1 class="post-title entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    
    									<?php if ( 'post' == get_post_type() ) : ?>
    								<div class="entry-meta">
    									<?php quest_post_meta(); ?>
    								</div><!-- .entry-meta -->
    							<?php endif; ?>
    
    								<?php if ( has_post_thumbnail() ) : ?>
    
    									<div class="post-image blog-normal effect slide-top">
    										<a href="<?php the_permalink() ?>"><?php the_post_thumbnail( 'blog-medium' ); ?></a>
    
    										<div class="overlay">
    											<div class="caption">
    												<a href="<?php the_permalink() ?>"><?php _e( 'View more', 'quest' ); ?></a>
    											</div>
    											<a href="<?php the_permalink() ?>" class="expand">+</a>
    											<a href="#" class="close-overlay hidden">x</a>
    										</div>
    									</div>
    
    								<?php endif; ?>
    
    									<div class="entry-content">
    										<?php the_excerpt() ?>
    									</div>
    
    								<footer class="entry-footer">
    									<?php quest_post_taxonomy( $view ); ?>
    								<?php quest_post_read_more(); ?>
    								</footer><!-- .entry-footer -->
    
    							</article><!-- #post-## -->
    
    							</article>
    
    						<?php endwhile; ?>
    
    							<?php quest_pagination( $pages = '', $range = 2 ); ?>
    
    						<?php else : ?>
    
    							<?php get_template_part( 'content', 'none' ); ?>
    
    						<?php endif; ?>
    
    					</main>
    					<!-- #main -->
    				</div>
    				<!-- #primary -->
    
    				<?php quest_try_sidebar( $view, 'right' ); ?>
    
    			</div>
    			<!-- .row -->
    		</div>
    		<!-- .container -->
    	</div>
    	<!-- .quest-row -->
    </div><!-- #content -->
  • Milan

    Hello @HeatherFeuer,

    Hope you have been well today. :slight_smile:

    I tried to open link you've mentioned in your question but got "page not found". I've attached screenshot for your confirmation.

    Now It seems to me that you've disabled that post type or removed ? Or something else ? If you don't mind I would like to check your site's configurations and custom post type setup. For that I'll need Support Staff Access and that you can grant us via WPMU DEV Dashboard > Support > Support Staff > Grant Access .

    Furthermore can I ask you to do little test ? Open up "archive-townships.php" file and just below line

    get_header();

    enter this line,

    die( 'hey I am archive of townships post type and being called successfully ) ;

    after this much changes, save file and try to view archive page, what you see there ? Can you share your results with us ?

    Let me know results and enable support staff access so we can move forward on this one. :slight_smile:

    With Gratitude and Warmest Regards,
    Milan Savaliya

  • HeatherFeuer

    Oops! I meant http://acgs.selfip.org/archive-townships/. Sorry about that! I edited the template and got the message, so it IS being called correctly. I have commented it out now.

    I have also granted access as requested. Thank you! The site is now live without using the archives for townships, but I would really like to be able to provide an alternate method for listing than the image map I am currently using.

  • Predrag Dubajic

    Hi Heather,

    I was doing some testing on my end with default WP theme and pagination works there without any issues so it's probably related to custom pagination your theme uses.

    Have you tried replacing custom theme pagination:
    <?php quest_try_sidebar( $view, 'right' ); ?>
    With WP default one:

    // Previous/next page navigation.
    the_posts_pagination( array(
    	'prev_text'          => __( 'Previous page', 'twentyfifteen' ),
    	'next_text'          => __( 'Next page', 'twentyfifteen' ),
    	'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>',
    ) );

    Best regards,
    Predrag

  • Predrag Dubajic

    Hi Heather,

    I have installed Quest theme and created archive-custompt.php file with this code you posted above:

    <?php
    /**
     * The template for displaying archive pages.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     *  Quest
     */
    
    get_header();
    $layout = quest_get_mod( 'layout_archive_style' ); ?>
    <!-- This is the archive template -->
    <?php get_template_part( 'partials/content', $layout ); ?>
    
    <?php get_footer(); ?>

    Checked the pagination and didn't have any issues with it.

    Have you tried activating your parent theme to check if there's something in child theme causing this?

    Best regards,
    Predrag

  • HeatherFeuer

    I tried moving back to the parent theme and still got a 404 on page 2. Please bear in mind that I have custom post types defined in CustomPress, one of which is townships. I have an archive template called archive-townships.php. It is THAT specific template that causes the 404. Previously, I was using a different custom post types plugin and I had NO problems with that archive template! That is why I suspect it might be something to do with CustomPress. It might also help to tell you that I tried the CustomPress archive template in Twenty Fifteen and had the exact same issue.

  • Milan

    Hello @HeatherFeuer,

    I hope you are well today. :slight_smile:

    Dear member I also tried to replicate issue with Quest Theme but got same results as my colleagues Predrag Dubajic got. I was able to navigate myself around archive listing easily. Pagination was working fine and didn't get any "Opps Page not Found" issue. So having that said we both can confirm that its not issue with theme you are using, so what remains then ? Other plugins ? Yes one of those can be cause of this issue too. So next step we need to take is to conduct plugin conflict test. :slight_smile:

    Its very easy test and you will get all the information about it here in our support manual as flowchart. :slight_smile:
    https://premium.wpmudev.org/manuals/using-wpmu-dev/getting-support/

    Once you conduct plugin conflict test will you please post back its results here ? Also Have you checked that other posts pagination is working fine ?

    Cheers,
    Milan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.