有人能给我讲讲,解释一下如何创建一些通过pretty link传递的“过滤器”吗?
让我自我解释一下,我有一个自定义的帖子类型,叫做"spectacle" 我有一个meta\\u键,其中包含了这场奇观的一系列日期。我知道如何提取我的日期,并对其进行过滤如果我明确地对我的显示进行一些过滤,我的问题不是从那里来的,我试图实现的是访问
http://myurl.com/spectacles (展示即将到来的眼镜-already done) http://myurl.com/spectacles/2014 (展示所有2014年奇观)http://myurl.com/spectacles/2014/01 (从2014年1月开始展示所有奇观)http://myurl.com/spectacles/2014/01/01 (从2014年1月1日起展示所有奇观)http://myurl.com/spectacle/name-of-the-spectacle (展示这一奇观—already done)
我只需要一种方法来启用这些永久链接并提取这些参数,这样我就可以做我想做的事情了,我已经有了过滤功能。
这就是我目前所做的:
// 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 );
现在我可以访问:http://myurl.com/spectacles/2014
但它显示的是主页,而不是归档程序。php
我无法访问: