与其说是一个问题,不如说是一个开放的讨论,因为我知道向post-type对象添加自定义参数确实有效,但我想知道这在技术上是否有任何错误。
基本上,注册帖子类型时:
$labels = array(
\'name\' => _x(\'Drews\', \'post type general name\'),
\'singular_name\' => _x(\'Drew\', \'post type singular name\'),
\'add_new\' => __(\'Add New\'),
\'add_new_item\' => __(\'Add New Item\'),
\'edit_item\' => __(\'Edit Item\'),
\'new_item\' => __(\'New Item\'),
\'view_item\' => __(\'View Item\'),
\'search_items\' => __(\'Search Items\'),
\'not_found\' => __(\'No Items found\'),
\'not_found_in_trash\' => __(\'No Items found in Trash\'),
\'menu_name\' => \'Archives\'
);
$rewrite = array(
\'slug\' => \'drews\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'show_in_menu\' => true,
\'query_var\' => \'drews\',
\'rewrite\' => $rewrite,
\'has_archive\' => true,
\'hierarchical\' => false,
\'supports\' => array(\'title\',\'editor\',\'author\',\'comments\'),
\'_drew_made_this\' => true
);
register_post_type(\'drews\',$args);
记下我的$args数组中的最后一行,“\\u draw\\u Make\\u this”设置为“true”。这使我可以通过几种有用的方式对此进行条件设置,比如在使用get\\u post\\u types()时如何过滤“\\u builtin”。正如我所说,我知道这是可行的,因为我正在使用它,但这是否有可能以任何奇怪的方式打破WordPress。