WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#21468 closed defect (bug) (invalid)

Custom Post Type Permalink Returns 404 Error

Reported by: imageac Owned by:
Milestone: Priority: normal
Severity: critical Version:
Component: Permalinks Keywords:
Focuses: Cc:

Description

Hi,

During WP 3.3.2, single-products.php was serving ' products ' custom post type. Since, I upgraded WordPress version from 3.3.2 to 3.4.1, I discovered permalink returns 404 error on Custom post type ' products '.

After adding following code in functions.php, it doesn't return 404 error, but redirect to homepage and still reluctant to serve requested content.

function produc_rewrite() {
    global $wp_rewrite;

    $wp_rewrite->add_permastruct('products', 'products/%postname%/', true, 1);

    add_rewrite_rule('products/([^/]+)/?$', 'index.php?post_type=products&postname=$matches[1]', 'top');

    $wp_rewrite->flush_rules(false); // !!!
}
add_action('init', 'produc_rewrite');

I also have tried to disable all plugin and deactivated current theme to default theme 'twentyeleven', but nothing fruitful. Please assist me to recover my content for ' products ' custom post type.

Regards

Change History (3)

#1 @dd32
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Trac is not a support avenue.

Please try the support forums.

Duplicate of #21417

#2 @imageac
9 years ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

#3 @Ipstenu
9 years ago

  • Keywords needs-patch needs-codex dev-feedback removed
  • Resolution set to invalid
  • Status changed from reopened to closed

Please post in the forums, not here, and you may want to include your CPT code as a pastebin link.

Note: See TracTickets for help on using tickets.