does someone could point me a lecture that could explain me how to create some "filter" passed by pretty link ?
Let me explain my self, I have a custom post type called "spectacle" and I have a meta_key who contain an array of dates for this spectacle. I know how to extract my date, and filter them if I give explicitly some filter to my display, my problem is not coming from there, what I'm trying to achieve, is to access
http://myurl.com/spectacles (show upcoming spectacles - already done) http://myurl.com/spectacles/2014 (show all 2014 spectacle) http://myurl.com/spectacles/2014/01 (show all spectacle from january 2014) http://myurl.com/spectacles/2014/01/01 (show all spectacle from january 1st 2014) http://myurl.com/spectacle/name-of-the-spectacle (show this spectacle - already done)
All i need to is a way to enable theses permalink and to extract theses parameters than i'll be able to do what I want, I already have my filtering functions.
This is what i've done so far :
// Register Custom Post Type
function build_cpt() {
$labels = array(
'name' => _x( 'Programmation', 'Post Type General Name', 'mlog_lang' ),
'singular_name' => _x( 'Spectacles', 'Post Type Singular Name', 'mlog_lang' ),
'menu_name' => __( 'Programmation', 'mlog_lang' ),
'all_items' => __( 'Tous les spectacles', 'mlog_lang' ),
'view_item' => __( 'Afficher ce spectacle', 'mlog_lang' ),
'add_new_item' => __( 'Ajouter un spectacle', 'mlog_lang' ),
'add_new' => __( 'Ajouter un spectacle', 'mlog_lang' ),
'edit_item' => __( 'Modifier un spectacle', 'mlog_lang' ),
'update_item' => __( 'Mettre à jour ce spectacle', 'mlog_lang' ),
'search_items' => __( 'Rechercher un spectacle', 'mlog_lang' ),
'not_found' => __( 'Aucun spectacle trouvé', 'mlog_lang' ),
'not_found_in_trash' => __( 'Aucun spectacle dans la corbeille', 'mlog_lang' ),
);
add_rewrite_tag( '%event-year%', '(\d{4})' );
//add_rewrite_tag( '%event-month%', '(\d{2})' );
//add_rewrite_tag( '%event-day%', '(\d{2}|\d{1})' );
$rewrite = array(
//'slug' => 'spectacles/%event-year%/%event-month%/%event-day%/',
'slug' => 'spectacles/%event-year%/',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'label' => __( 'programmation', 'mlog_lang' ),
'description' => __( 'Liste des spectacles', 'mlog_lang' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'revisions' ),
'taxonomies' => array(),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => false,
'show_in_admin_bar' => false,
'menu_position' => 4,
'menu_icon' => 'dashicons-groups',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'programmation', $args );
Now I can access :
but it shows the home page instead of archive-programmation.php
And I can't access :
add_rewrite_rule
for some examples.add_rewrite_tag( '%event-year%', '(\d{4})' );
I can access myurl.com/spectacle/2014 but I can't access myurl.com/spectacle AND the second problem is that myurl.com/spectacle/2014 show me the front-page instead of the archive-spectacle.php !