在自定义帖子类型中创建页面

时间:2015-12-14 18:28:26

标签: wordpress custom-post-type

我的存档页面和单页运行良好,我也需要自定义页面。例如,www.site.com/dates是归档页面,www.site.com/dates/product1是单页。我也需要几个月的页面,所以www.site.com/dates/januarywww.site.com/dates/february等应该正常工作。

$months = array('january', 'february', 'march', ...);

$args = array(
    'labels' => array(
        'name' => 'Dates',  
        ),
    'rewrite' => array(
        'slug' => 'dates'
        ),
    'public' => true,
    'publicly_queryable' => true,
    'has_archive' => true,
    'supports' => array('title', 'excerpt')
    );
register_post_type('date-posttype', $args);


foreach(months as $month)
{
    $args = array(
        'labels' => array('name' => $month),
        'hierarchical' => true,
        'sort' => true,
        'query_var' => $month_var
        );
    register_taxonomy($month_var, 'date-posttype', $args);
}

我可以使用自定义代码在这些月份页面工作时显示数据,但是如何让它们工作?

0 个答案:

没有答案
相关问题