0

I use the default Wordpress permalinks as shortlinks on my site, and just noticed that they are not working for custom post type links. Instead they give a 404 error.

These work for for the 'post' post type, but not for anything else.

Is this normal?

Here is the custom post type declaration:

function register_fact_post_type() {
    $labels = array(
        'name'               => _x( 'Facts', 'post type general name'),
        'singular_name'      => _x( 'Fact', 'post type singular name'),
        'menu_name'          => _x( 'Facts', 'admin menu'),
        'name_admin_bar'     => _x( 'Fact', 'add new on admin bar'),
        'add_new'            => _x( 'Add New', 'Fact'),
        'add_new_item'       => __( 'Add New Fact'),
        'new_item'           => __( 'New Fact'),
        'edit_item'          => __( 'Edit Fact'),
        'view_item'          => __( 'View Fact'),
        'all_items'          => __( 'All Facts'),
        'search_items'       => __( 'Search Facts'),
        'parent_item_colon'  => __( 'Parent Facts:'),
        'not_found'          => __( 'No Facts found.'),
        'not_found_in_trash' => __( 'No Facts found in Trash.')
        );

    $args = array(
        'labels'             => $labels,
        'public'             => true,
        'publicly_queryable' => true,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'query_var'          => true,
        'rewrite'            => array( 'slug' => 'facts' ),
        'capability_type'    => 'post',
        'has_archive'        => true,
        'hierarchical'       => false,
        'menu_position'      => null,
        'supports'           => array( 'title', 'thumbnail', 'comments' ),
        'taxonomies' => array('category', 'post_tag')
        );

    register_post_type( 'fact', $args );
}
add_action( 'init', 'register_fact_post_type', 1);
4
  • It depends on how you registered your custom post type - could you share the arguments you are using?
    – bosco
    May 27, 2016 at 1:16
  • Does flushing rewrite rules correct the issue? Do you get redirected to the pretty permalink URL?
    – Tom J Nowell
    May 27, 2016 at 1:48
  • @bosco - I added the custom post type declaration code :)
    – jetlej
    May 27, 2016 at 10:37
  • @TomJNowell - No I tried that :/
    – jetlej
    May 27, 2016 at 10:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.