WordPress.org

Forums

WP-PageNavi
Page Navigation error on CATEGORY and SEARCH (2 posts)

  1. LeoStorch
    Member
    Posted 4 years ago #

    My WP is on the root of my domain, I'm using a custom post type and I followed all hierarchy of wp themes, but the Pagenavi isn't working ok with CATEGORY.

    http://www.domain.com/CATEGORY BASE NAME/2006/ - Works ok, all the posts appears with the pagination, but when I click to move to another page, for example: http://www.domain.com/CATEGORY BASE NAME/2006/page/2/ , It returns 404!

    I've alread tried to change the permalinks back to default and save but the problem remains.

    CATEGORY.php

    $CatName = single_cat_title('',false);
    $cat_id=get_cat_id($CatName);
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $count=1; query_posts('cat='.$cat_id.'&post_type=eventos&paged='.$paged.'&post_per_page=10');?>

    PS: Pagenavi is working perfect in with taxonomy, but I have similar problems with the SEARCH REASULTS: http://www.domain.com/page/3/?s=keyword

    Any ideas what's wrong? Thanks!

    http://wordpress.org/extend/plugins/wp-pagenavi/

  2. Samy RABIH
    Member
    Posted 4 years ago #

    I was able to make this plugin working with some changes (in fact, for unknown reasons, get_pagenum_link() doesn't execute in the right way the following test :

    if ( !$wp_rewrite->using_permalinks() || is_admin() ) {

    So, I duplicate this function in my theme :

    function get_pagenum_link_custom($pagenum = 1,$force=true) {
    	global $wp_rewrite;
    
    	$pagenum = (int) $pagenum;
    
    	$request = remove_query_arg( 'paged' );
    
    	$home_root = parse_url(home_url());
    	$home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
    	$home_root = preg_quote( trailingslashit( $home_root ), '|' );
    
    	$request = preg_replace('|^'. $home_root . '|', '', $request);
    	$request = preg_replace('|^/+|', '', $request);
    
    	if ( $force==true) {
    		$base = trailingslashit( get_bloginfo( 'url' ) );
    
    		if ( $pagenum > 1 ) {
    			$result = add_query_arg( 'paged', $pagenum, $base . $request );
    		} else {
    			$result = $base . $request;
    		}
    	} else {
    		$qs_regex = '|\?.*?$|';
    		preg_match( $qs_regex, $request, $qs_match );
    
    		if ( !empty( $qs_match[0] ) ) {
    			$query_string = $qs_match[0];
    			$request = preg_replace( $qs_regex, '', $request );
    		} else {
    			$query_string = '';
    		}
    
    		$request = preg_replace( '|page/\d+/?$|', '', $request);
    		$request = preg_replace( '|^index\.php|', '', $request);
    		$request = ltrim($request, '/');
    
    		$base = trailingslashit( get_bloginfo( 'url' ) );
    
    		if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
    			$base .= 'index.php/';
    
    		if ( $pagenum > 1 ) {
    			$request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
    		}
    
    		$result = $base . $request . $query_string;
    	}
    
    	$result = apply_filters('get_pagenum_link', $result);
    
    	return $result;
    }

    And I modified the WP-pagenavi plugin to use this function in _wp_pagenavi_single().

    It should be useful to post a patch for this problem :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic