• Jase

    (@jasewarner)


    Hey,

    I’m hoping somebody can shed some light on an issue that I’m experiencing with the Custom Post Type Permalinks plugin.

    I’m currently developing a website and have made use of the custom post types and taxonomies. The problem is that while the permalinks and archive/taxonomy pages work fine, I’m getting 404s on all singe post pages.

    Here’s the code I’m using in my functions.php file to create the custom post types:

    // custom post types
    add_action( 'init', 'create_post_type' );
    function create_post_type() {
        // create work post type
        register_post_type( 'work',
            array(
                'labels' => array(
                    'name' => __( 'Work' ),
                    'singular_name' => __( 'Work' ),
                    'add_new' => __('Add New Work')
                ),
                'public' => true,
                'menu_position' => 5,
                'has_archive' => true
            )
        );
        // create blog post type
        register_post_type( 'blog',
            array(
                'labels' => array(
                    'name' => __( 'Blog' ),
                    'singular_name' => __( 'Post' ),
                    'add_new' => __('Add New Blog Post')
                ),
                'public' => true,
                'menu_position' => 5,
                'has_archive' => true
            )
        );
    //    flush_rewrite_rules(); // dev purposes only
    }

    And here’s what I’m using to create the taxonomies in the same file:

    // custom categories
    add_action( 'init', 'create_category' );
    function create_category() {
        register_taxonomy(
            'work-category',
            'work',
            array(
                'label' => __( 'Work Categories' ),
                'rewrite' => array( 'slug' => 'work' ),
                'hierarchical' => true,
                'show_ui' => true,
                'show_admin_column' => true
            )
        );
        register_taxonomy(
            'blog-category',
            'blog',
            array(
                'label' => __( 'Blog Categories' ),
                'rewrite' => array( 'slug' => 'blog' ),
                'hierarchical' => true,
                'show_ui' => true,
                'show_admin_column' => true
            )
        );
    }

    Now, to me, all of the above looks okay. So, thus far, I’m stumped as to what the problem is.

    Here’s how I have set up my permalinks:

    • ‘work’ is: /%work-category%/%postname%/ (has_archive: true / with_front: true)

    • ‘blog’ is: /%blog-category%/%postname%/ (has_archive: true / with_front: true)

    “Use custom permalink of custom taxonomy archive” is unchecked.

    Here’s an example how the permalinks are currently working (or not working, as the case may be):

    http://176.32.230.6/timgrewcock.com/work/ (works fine)
    http://176.32.230.6/timgrewcock.com/work/acting/ (works fine)
    http://176.32.230.6/timgrewcock.com/work/acting/something-2/ (doesn’t work)

    I’ve just discovered that changing the common permalink settings to default (e.g. http://www.site.com/?p=123) gets everything working.
    So, it seems to be a problem with the postname being called.
    I’ve checked and I don’t have any categories or pages named the same as the two post types I created.

    Anybody have any ideas at all?

  • The topic ‘[Plugin: Custom Post Type Permalinks] Single Post 404s’ is closed to new replies.