[wp-trac] [WordPress Trac] #21417: Custom Post Type Permalink Returns 404 Error
WordPress Trac
wp-trac at lists.automattic.com
Tue Jul 31 05:42:22 UTC 2012
#21417: Custom Post Type Permalink Returns 404 Error
-------------------------------+------------------------------
Reporter: imageac | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Permalinks | Version: 3.4.1
Severity: critical | Resolution:
Keywords: reporter-feedback |
-------------------------------+------------------------------
Comment (by imageac):
After upgrading Wordpress to 3.4.1, I faced 404 error with 'paged'
categories, but it was soon resolved with assistance available in
ticket:21209. I added following code to the theme's functions.php file.
{{{
function hc_init() {
global $wp_rewrite;
//add rewrite rule.
add_rewrite_rule("author/([^/]+)/page/?([0-9]{1,})/?$",'index.php?author_name=$matches[1]&paged=$matches[2]','top');
add_rewrite_rule("(.+?)/page/?([0-9]{1,})/?$",'index.php?category_name=$matches[1]&paged=$matches[2]','top');
$wp_rewrite->flush_rules(false);
}
add_action('init','hc_init');
}}}
As I explained earlier that my above code was super fit, and had no
problem related to permalink and/or custom post type before upgrade to
3.4.1.
My steps:
1. Yes, I added code mentioned-above to the theme's functions.php file.
2. Yes, flushed rewrite rules by visiting the Permalink Settings screen.
3. Yes, I created a new product (Product 1).
4. But, when I visited /products/product-1/. The post returns 404 error as
tested it.
Please help me to fix 404 error with custom post type.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21417#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list