• Resolved jnbn

    (@jnbn)


    I have been developing a new theme for my blog. I have both tried using wp_pagenavi plugin and normal pagination by myself. It both worked well until the 7th page. (previous,first and next buttons)

    But at 7th page and other pages(if there are) it gives me 404 error.

    When i change my custom permalink option(/%category%/%postname%-%post_id%.html) to default (which is like ?p=123) it works.

    I really don’t want to change my permalink options because i have a lot of indexed web pages at search engines.

    Waiting for replies,advices or solutions
    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jnbn

    (@jnbn)

    I found the solution myself:

    I was using
    query_posts("&paged=$page&posts_per_page=7");

    But it makes the url_rewriting by the option which we already set by hand (Reading Options)

    so i removed the posts_per_page from the template.
    I just set it from the admin panel..

    I’ve been slamming my head on the desk for at least 2 hours on this, but you’re solution worked. God i’m so glad. Thanks!

    Doesn’t help. Page 2 onwards still gives a 404. I am on WP 2.6.1. Any ideas? My permalink structure is:

    /%category%/%postname%

    I am having a similar problem… my permalink is set to Custom: /%category%/%post_id%, and I am using WP 2.7.1 with the WordPress Default theme.

    When I go to a category page (let’s call it ‘stuff’) like https://www.mysite.com/wordpress/stuff it correctly shows the posts for the first page of the category, and if you hover over the Older Entries links is says
    https://www.mysite.com/wordpress/stuff/page/2

    but if you click it, you get a 404 Error.

    I have posted a bug in the WordPress tracker, but if anybody knows of a solution it would be greatly appreciated.

    Thanks

    I re-wrote the barefoot plugin for WP 2.7.1 and this fixed my problem… maybe it will help others as well. It also works with WP-PageNavi…

    [code]

    <?php
    /*
    Plugin Name: Fix Paging in Category Listings
    Plugin URI:
    Description: Fixes a bug where next/previous page links are broken in category listings
    Version: 0.6
    Author: Doug Smith (modified by Jeff Sherk)
    Author URI:

    Modified on March 23, 2009 by Jeff Sherk for WordPress 2.7.1

    Based on original plugin info listed below:
    Plugin Name: Fix Paging in Category Listings
    Plugin URI: https://www.thinkbarefoot.com
    Description: Fixes a bug where next/previous links are broken in category by year/month listings
    Version: 0.5
    Author: Doug Smith
    Author URI: https://www.thinkbarefoot.com

    Copyright 2007 Doug Smith (email: [email protected])

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    */

    /**
    * Function to fix problem where next/previous buttons are broken on list
    * of posts in a category when the custom permalink string is:
    * /%category%/%year%/%monthnum%/%postname%/
    * The problem is that with a url like this:
    *
    * /category/2007/10/page/2
    *
    * the 'page' looks like a post name, not the keyword "page"
    *
    * MODIFIED ON March 23, 2009 by Jeff Sherk
    * Permalink structure was /%category%/%post_id% which looked like
    * https://www.mysite.com/wordpress/news/27
    * When attempting to go to another page, it looked like this
    * https://www.mysite.com/wordpress/news/27/page/2
    * but would generate a 404 error .
    *
    * This modification takes $query_string['category_name'] and chops the '/page'
    * off the end. It also takes $query_string['paged'] and sets it equal to
    * $query_string['p'], and then unsets $query_string['p'].
    * 'p' is not needed, but 'paged' is needed in order to make it work correctly
    */
    function fix_page_in_category_from_query_string($query_string) {

    //Check to see if the 'p' and 'category_name' are set in $query_string
    if ( isset($query_string['category_name']) && isset($query_string['p']) ) {

    $category_name = $query_string['category_name'];
    $category_len = strlen($category_name);

    //Check to see if the 'category_name' has '/page' on the end of it
    if (substr($category_name, $category_len-5,5) == '/page') {

    //Remove '/page' from the end of 'category_name'
    $query_string['category_name'] = substr($query_string['category_name'],0,$category_len-5);

    //Set 'paged' equal to the page you want to go to
    $query_string['paged'] = $query_string['p'];

    //Unset 'p' since we don't need it anymore because we set 'paged' instead
    unset($query_string['p']);
    }
    }
    return $query_string;
    }

    add_filter('request', 'fix_page_in_category_from_query_string');

    ?>

    [/code]

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Permalinks and Paging’ is closed to new replies.