自定义帖子类型及其对应的主题文件

时间:2011-05-16 作者:mktggirl

我有一个名为“business\\u selled”的自定义帖子类型,它没有读取archive-business\\u selled。php而是读取索引。php。但是,自定义帖子类型为,正确读取single-business\\u Seld。php。

这就是我注册自定义帖子类型的方式(最初是通过single-business\\u sell.php工作时使用的插件),然后我手动将以下代码添加到函数中。php:

register_post_type(\'Business_Sold\', array(  \'label\' => \'Businesses Sold\',\'description\' => \'\',\'public\' => true,\'show_ui\' => true,\'show_in_menu\' => true,\'capability_type\' => \'post\',\'hierarchical\' => false,\'rewrite\' => array(\'slug\' => \'\'),\'query_var\' => true,\'has_archive\' => true,\'menu_position\' => 5,\'supports\' => array(\'title\',\'editor\',\'excerpt\',\'trackbacks\',\'custom-fields\',\'comments\',\'revisions\',\'thumbnail\',\'author\',\'page-attributes\',),\'taxonomies\' => array(\'category\',\'post_tag\',),\'labels\' => array (
  \'name\' => \'Businesses Sold\',  
  \'singular_name\' => \'Business Sold\',  
  \'menu_name\' => \'Businesses Sold\',  
  \'add_new\' => \'Add Business Sold\',  
  \'add_new_item\' => \'Add New Business Sold\',  
  \'edit\' => \'Edit\',  
  \'edit_item\' => \'Edit Business Sold\',  
  \'new_item\' => \'New Business Sold\',  
  \'view\' => \'View Business Sold\',  
  \'view_item\' => \'View Business Sold\',  
  \'search_items\' => \'Search Businesses Sold\',  
  \'not_found\' => \'No Businesses Sold Found\',  
  \'not_found_in_trash\' => \'No Businesses Sold Found in Trash\',  
  \'parent\' => \'Parent Business Sold\',  
),) );
你知道为什么会这样吗?

1 个回复
SO网友:alexndm

在函数中注册自定义帖子时。php添加此\'has_archive\' => \'book-list\'然后你的archive-business\\u就卖了。php将参阅本文了解详细信息http://www.wpmods.com/wordpress-3-1-custom-post-type-archives

或者只使用插件(例如http://wordpress.org/extend/plugins/simple-custom-post-type-archives)

结束

相关推荐