Showing additional pages that don't exist


#1

Hi,

I'm noticing a problem with pagination when using the numbers to go to additional pages. When I go to a category page and scroll to the bottom there it shows additional numbered pages where none exist. When I click any other the numbers it shows the same page I am currently on. How can I prevent it from shows additional pages when none exist yet? Thanks!


#2

Also in checking the code it appears that it's the pagenav that needs to be changed. Where would I find the edit this in the files? Thanks!


#3

I found the page under rtp-default-functions.php and made the edit from 'total' => $wp_query->max_num_pages,

to 'total' => $wp_query->multipart,

the only problem with this is how do I do this under the child theme instead of the parent theme. I created a lib folder and the same file under my child theme folder but it doesn't identify the edit. It only takes affect under the parent folder.


#4

Hi, For implementing the same using the child theme, you can uncomment the following line https://github.com/rtCamp/rtpanel-child-theme/blob/master/lib/rtp-custom-hooks-applied.php#L19

Once that is done go to the end of the rtp-custom-hooks-applied.php file and paste the following code.

function rtp_custom_archive_pagination() {   
    /* Page-Navi Plugin Support with WordPress Default Pagination */  
    if ( !rtp_is_bbPress() ) {  
        if ( !is_singular() ) {  
            global $wp_query, $rtp_post_comments;  
            if ( isset( $rtp_post_comments['pagination_show'] ) && $rtp_post_comments['pagination_show'] ) {  
                if ( ( $wp_query->max_num_pages > 1 ) ) { ?>  
                    <?php  
                        echo paginate_links( array(  
                                'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),  
                                'format' => '?paged=%#%',  
                                'current' => max( 1, get_query_var('paged') ),  
                                'total' => $wp_query->multipart,  
                                'prev_text' => esc_attr( $rtp_post_comments['prev_text'] ),  
                                'next_text' => esc_attr( $rtp_post_comments['next_text'] ),  
                                'end_size' => $rtp_post_comments['end_size'],  
                                'mid_size' => $rtp_post_comments['mid_size']  
                            ) ); ?>  
                    <?php  
                }  
            } elseif ( function_exists( 'wp_pagenavi' ) ) {  
                wp_pagenavi();  
            } elseif ( get_next_posts_link() || get_previous_posts_link() ) { ?>  
                  
                    <?php if ( get_next_posts_link() ) { ?>
<?php next_posts_link( __( '← Older Entries', 'rtPanel' ) ); ?>
<?php } ?> <?php if ( get_previous_posts_link() ) { ?>
<?php previous_posts_link( __( 'Newer Entries →', 'rtPanel' ) ); ?>
<?php } ?> <?php } } } } add_action( 'rtp_hook_archive_pagination', 'rtp_custom_archive_pagination' );

So basically you would have to remove the parent hook and add a hook of your own.


#5

Thank you Joshua! But when I looked in the lib folder the rtp-custom-hooks-applied.php doesn’t exist. So I just copied the code from the rtp-custom-hooks-applied.php file and created a lib folder in the child theme folder and reversed the parent back to $wp_query->max_num_pages. The rtp-custom-hooks-applied.php under lib in the child theme didn’t change it multipart. Is there something I’m missing? Thanks for your help.


#6

Also, I can’t add a functions.php file to my child theme folder. Is there a way to do this. Should I be able to move it to my child folder? Thanks


#7

Have you created your child theme from scratch?


#8

Yes, I created from scratch. I can’t do the code in the way you described? I just looked up rtPanel child theme I didn’t know that you guys had one already set up for people to use. But even if I put the rtpanel child function.php file in my child theme folder my site receives an error. I’m not sure what to do :frowning:


#9

Ok try doing this then. If you don’t have a functions.php file create an empty one and put the following code in it. If you have one then just append the following code to it.

  
function customtheme_remove_parent_hooks() {  
     
    remove_action( 'rtp_hook_archive_pagination', 'rtp_default_archive_pagination' );  
      
}  
add_action( 'init', 'customtheme_remove_parent_hooks' );  

Follow this code with the code provided in the older reply.


#10