WordPress.org

Ready to get started?Download WordPress

Forums

Better Search
[resolved] Restrict number of pagination elements (5 posts)

  1. designerbydesign
    Member
    Posted 9 months ago #

    Hello,

    I have been doing some work with the better search plugin and noticed large result sets produced many pagination items, this looked bad on my setup so I added some custom functionality to the function named: get_bsearch_footer().

    At line 408: Replace

    for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it.
    	{
    		$ppage = $limit*($i - 1);
    		if ($ppage == $page){
    		$output .=  ("<b>$i</b>\n");} // If current page don't give link, just text.
    		else{
    			$output .=  ("<a href=\"".get_option('siteurl')."/?s=$s&limit=$limit&bpaged=$ppage\">$i</a> \n");
    		}
    	}

    With:

    //EDITS BY J NORTON
    	$pagination_range = 4;
    	//END EDITS BY J NORTON
    	for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it.
    	{
    
    		//EDITS BY J NORTON
    		$current = ($match_range[0]/$limit) + 1; // Current page number.
    		if($i >= $current+$pagination_range && $i <$pages){
    			if($i == $current+$pagination_range){
    				$output .= '&hellip;&nbsp;';
    			}
    			continue;
    		}
    		if($i < $current-$pagination_range+1 && $i <$pages){
    			continue;
    		}
    		//END EDITS BY J NORTON
    		$ppage = $limit*($i - 1);
    		if ($ppage == $page){
    		$output .=  ("<span class='current'>$i</span>\n");} // If current page don't give link, just text.
    		else{
    			$output .=  ("<a href=\"".get_option('siteurl')."/?s=$s&limit=$limit&bpaged=$ppage\">$i</a> \n");
    		}
    	}

    It would be nice to integrate this into the core plugin and provide the ability to set the pagination padding from the UI. Also, it would be good to be able to enter a CSS class name for the pagination container from the UI.

    Cheers :)

    http://wordpress.org/plugins/better-search/

  2. Ajay
    Member
    Plugin Author

    Posted 9 months ago #

    Hi,

    Thanks for this. I'll implement this in the next version.

    May I understand what you mean by "Pagination padding" ?

  3. Taylor
    Member
    Posted 8 months ago #

    Has this been integrated yet?

  4. Ajay
    Member
    Plugin Author

    Posted 8 months ago #

    Taylor,

    It's not been implemented yet. I have this and several changes to put through to Better Search, but I'm going to be on the road whole of this week and next so it will be a while before I get to this.

  5. Taylor
    Member
    Posted 8 months ago #

    Gotcha.

Reply

You must log in to post.

About this Plugin

About this Topic