Support » Plugin: Posts in Page » Posts in Page Pagination is broken

  • Resolved pacaso1982

    (@pacaso1982)


    I use this plugin on probably 30-40 sites, and it looks like the latest update has wiped out the pip-nav, which is what’s being used to target and style the pagination.

    Is it possible to please add the PIP-nav div back in, and push a new update. This has broken all of my sites.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Eric Amundson

    (@sewmyheadon)

    Howdy @pacaso1982 – that’s no good.

    Two questions:

    1. Can you confirm the exact version you’re using now?
    2. Can you post an example of the shortcode you’re using on a site or two?

    I’ll investigate more on this end in the meantime.

    Thanks,
    Eric

    Eric,
    Thank you for getting back to me.

    Posts in Page Version is: 1.4.2

    Here’s the shortcode I’m using:
    [ic_add_posts showposts=’10’ paginate=’yes’ category=’essential-reading’ template=’blog-item.php’]

    Thank you again for investigating.

    – Anthony Ramirez

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Hi Anthony,

    I found the issue.

    Interestingly, the function we use to output those links is the same in 1.4.2 as it was in the last few versions.

    The last time that the function that outputs the navigation changed was 11 months ago and it was to correct some bad syntax. At the time, we had:

    return "<div class='pip-nav'>$prev_link $next_link</ul></div>";

    and now, it’s:

    return "<ul class='pip-nav'>$prev_link $next_link</ul>";

    The mistake in the first one was that there’s no opening <ul>.

    While those changes were made a while ago in the codebase, I don’t think they were released until the last few weeks.

    If you inspect the code, you still see the pagination, right? Is it just that it’s not picking up the styles that you had previously assigned it because of no wrapping div?

    I’ve tried a fresh install on my testbed of 1.4.2 directly from .org and pagination is working as it should for me using multiple themes but it is, of course without the wrapping div.

    Interestingly, this update has tweaked at least one of our sites too.

    I’m working on an update now and will push it soon and ping you.

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Howdy Anthony,

    I’ve just pushed release 1.4.3 which corrects the missing <div class='pip-nav'> and the ul nested inside it.

    Please update a site and confirm that this fixes your issue.

    Thanks,
    Eric

    Eric,
    Thank you again for investigating. I am extremely happy to know that you’ve found the issue and are working to push a new release.

    And yes the pagination is still available, it’s just an unclassed

      with no wrapping <div>.

      Thank you again. I’ll look forward to hearing from you about this update, so that I can update all of my sites.

      – Anthony Ramirez

    Eric,
    I have updated all of my sites globally that are running the plugin – and it still seems to be missing the wrapping div.

    I have cleared the hosting cache as well as browser cache, and no change.

    Here are 2 sites that are running the shortcode with pagination:
    http://petlandcares.com/essential-reading/
    https://directtechdmv.com/blog/

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Hi Anthony,

    I’m positive that the wrapping div is in the code and being output. I upgraded a site myself and saw the change.

    I’m wondering if you or your theme or a plugin are doing something special with the navigation? By default, it’s not numbered; just next and previous links.

    Are you using a filter to hook into PiP and change the pagination?

    Eric,
    I definitely believe you. Just not sure why it would not be updating for me. I’ve checked another site that I’m running the plugin as well. Same result.

    Eric,
    I do have a custom function working with the PIP-Nav to allow for numbers as well.

    I can share that function with you if you would like.

    Plugin Author Eric Amundson

    (@sewmyheadon)

    Yes, please.

    // Add pagination with 1,2,3 numbers to the "Posts In Page" plugin.
    class ICPagePosts_Paginate_With_Numbers {
    
    	public function __construct( ) {
    		add_filter('posts_in_page_results', array( &$this, 'get_wp_query' ));
    		add_filter('posts_in_page_paginate', array( &$this, 'paginate_links' ));
    	}
    
    	public function get_wp_query($posts){
    		$this->posts = $posts;
    		return $posts;
    	}
    
    	public function paginate_links($html){
    		$obj = get_queried_object();
    		$posts = $this->posts;
    
    		if (is_archive() || is_tax()) {
    			if ($obj->taxonomy == 'tag'){ $obj->taxonomy = 'post_tag'; }
    			$page_url = get_term_link($obj);
    		} elseif(is_post_type_archive() ) {
    			$page_url = get_post_type_archive_link( get_query_var('post_type') );
    		} else {
    			$page_url = get_permalink( $obj->ID );
    		}
    
    		$page = isset( $_GET['page'] ) ? $_GET['page'] : 1;
    		$total_pages = $posts->max_num_pages;
    		$per_page = $posts->query_vars['posts_per_page'];
    		$curr_page = ( isset( $posts->query_vars['paged'] ) && $posts->query_vars['paged'] > 0	) ? $posts->query_vars['paged'] : 1;
    		$prev = ( $curr_page && $curr_page > 1 ) ? '<li><a href="'.$page_url.'?page='. ( $curr_page-1 ).'">Previous</a></li>' : '';
    		$next = ( $curr_page && $curr_page < $total_pages ) ? '<li><a href="'.$page_url.'?page='. ( $curr_page+1 ).'">Next</a></li>' : '';
    		$numbers = '';
    		for ($i = ($curr_page - 2); $i < ($curr_page + 3); $i++){
    			if ($i == $curr_page) {
    				$numbers .= '<li class="current">' . $i . '</li>';
    			} elseif ($i < 1) {
    				//do nothing because there are no links before page 1
    			} elseif ($i > $total_pages) {
    				//do nothing. we don't want to paginate pages that don't exist.
    			} else {
    			 	$numbers .= '<li><a href="'.$page_url.'?page='. $i .'">' . $i . '</a></li>';
    			}
    		}
    		return '<ul>' . $prev . $numbers . $next . '</ul>';
    	}
    }
    new ICPagePosts_Paginate_With_Numbers();

    It would be nice to have this function as part of the plugin.

    • This reply was modified 1 year, 7 months ago by pacaso1982.
    Plugin Author Eric Amundson

    (@sewmyheadon)

    It would be nice to have this function as part of the plugin.

    Agreed. Feel free to submit a PR on GitHub. 🙂

    Looks like you’re hooking in and overriding the pagination so you won’t pick up the changes that I pushed.

    Can you tweak your paginate_links() so that, instead of returning:

    return '<ul>' . $prev . $numbers . $next . '</ul>';

    You have:

    return '<div class='pip-nav'><ul>' . $prev . $numbers . $next . '</ul></div>';

    Eric, this has worked. Thank you so much! You’ve been fantastic.

    Plugin Author Eric Amundson

    (@sewmyheadon)

    > Eric, this has worked. Thank you so much! You’ve been fantastic.

    Blammo! I’m really glad to hear it @pacaso1982 and I’m happy to help. Since you’ve used the plugin so extensively, I’d love to hear any feature requests or other feedback you might have. Please feel free to submit issues in GitHub.

    We’re considering a commercial upgrade to this plugin too but don’t have any ETA yet.

    Cheers!
    Eric

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Posts in Page Pagination is broken’ is closed to new replies.