Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter pacaso1982

    (@pacaso1982)

    Thank you again, and I think I may requests some feature updates.

    Thread Starter pacaso1982

    (@pacaso1982)

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

    Thread Starter pacaso1982

    (@pacaso1982)

    // 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 5 years, 11 months ago by pacaso1982.
    Thread Starter pacaso1982

    (@pacaso1982)

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

    Thread Starter pacaso1982

    (@pacaso1982)

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

    Thread Starter pacaso1982

    (@pacaso1982)

    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.

    Thread Starter pacaso1982

    (@pacaso1982)

    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:
    https://petlandcares.com/essential-reading/
    https://directtechdmv.com/blog/

    Thread Starter pacaso1982

    (@pacaso1982)

    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

    Thread Starter pacaso1982

    (@pacaso1982)

    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

Viewing 9 replies - 1 through 9 (of 9 total)