samedi 9 mai 2015

archive-{post_type}.php breaking when slug is changed

So I have a custom post type called 'events' which is all working fine provided that the slug is the same as the custom post type name. i.e. http://ift.tt/1RnRsh1. Wordpress leverages the archive-events.php nicely

The problem however is if I change the page hierarchy to http://ift.tt/1ciAlNb . Now Wordpress no longer uses the archive-events.php

Could the issue be in the re-write rules? I've tried several changes but nothing seems to resolve this. Here's the code:

//* Add Events post type...
$event_labels = array( 
    'name'                  => _x( 'Events', 'Post Type General Name', 'events' ),
    'singular_name'         => _x( 'Event', 'Post Type Singular Name', 'events' ),
    'all_items'             => __( 'All Events', 'events' ),
    'add_new'               => __( 'Add New', 'events' ),
    'add_new_item'          => __( 'Add New Event', 'events' ),
    'edit_item'             => __( 'Edit Event', 'events' ),
    'new_item'              => __( 'New Event', 'events' ),
    'view_item'             => __( 'View Event', 'events' ),
    'search_items'          => __( 'Search Events', 'events' ),
    'not_found'             => __( 'No Event found', 'events' ),
    'not_found_in_trash'    => __( 'No Events found in Trash', 'events' ),
    'parent_item_colon'     => __( 'Parent Event:', 'events' ),
    'menu_name'             => __( 'Events', 'events' ),
);

$event_args = array( 
    'labels'                => $event_labels,
    'hierarchical'          => false,
    'description'           => 'Events.',
    'supports'              => array( 'title', 'editor', 'thumbnail' ),
    'public'                => true,
    'show_ui'               => true,
    'show_in_menu'          => true,
    'menu_icon'             => 'dashicons-calendar',
    'menu_position'         => 5,
    'show_in_nav_menus'     => true,
    'publicly_queryable'    => true,
    'exclude_from_search'   => false,
    'has_archive'           => true,
    'query_var'             => 'events',
    'can_export'            => true,
    'rewrite'               => array( 
        'slug'              => 'news/events', 
        'with_front'        => true,
        'feeds'             => true,
        'pages'             => true
    ),
    'capability_type' => 'post'
);

register_post_type( 'events', $event_args );

Any suggestions would be appreciated!!

Aucun commentaire:

Enregistrer un commentaire