我创建了一个名为mfg_ppn
还有一种自定义分类法mfg_pp
, 它们被引用为$this->cpt_promotion_news
和$this->cpt_promotion
如果你想知道的话。
管理中的一切看起来都很好,我可以轻松地将分类法分配给自定义帖子。但是当我使用http://example.com/promotion/company
我没有得到任何职位,即使有12个职位绑定到该特定术语。
下面是我用于注册帖子类型的PHP代码:
// Register campaign news:
register_post_type($this->cpt_promotion_news, array(
\'labels\' => array(
\'name\' => __(\'Campaign Posts\', $this->plugin_locale),
\'singular_name\' => __(\'Promotion Campaign\', $this->plugin_locale),
\'menu_name\' => __(\'Promotion\', $this->plugin_locale),
\'all_items\' => __(\'All Campaign Posts\', $this->plugin_locale),
\'add_new\' => __(\'Add New Post\', $this->plugin_locale),
\'add_new_item\' => __(\'Add New Campaign Post\', $this->plugin_locale),
\'edit_item\' => __(\'Edit Post\', $this->plugin_locale),
\'new_item\' => __(\'New Post\', $this->plugin_locale),
\'view_item\' => __(\'View Post\', $this->plugin_locale),
\'search_items\' => __(\'Search Posts\', $this->plugin_locale),
\'not_found\' => __(\'No posts found\', $this->plugin_locale),
\'not_found_in_trash\' => __(\'No posts found in trash\', $this->plugin_locale),
\'parent_item_colon\' => __(\'Post parent:\', $this->plugin_locale)
),
\'description\' => __(\'News for a partner promotion campaign.\', $this->plugin_locale),
\'public\' => true,
\'exclude_from_search\' => true,
\'show_in_nav_menus\' => true,
\'menu_position\' => 25,
\'show_in_menu\' => true,
\'map_meta_cap\' => true,
\'capabilities\' => array( \'manage_options\' ),
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'comments\' ),
\'taxonomies\' => array( $this->cpt_promotion ),
\'has_archive\' => true,
\'rewrite\' => array(
\'slug\' => __(\'promotion-post\', $this->plugin_locale)
)
));
下面是注册分类法的代码:
// Register promotion campaigns:
register_taxonomy($this->cpt_promotion, $this->cpt_promotion_news, array(
\'labels\' => array(
\'name\' => __(\'Promotion Campaigns\', $this->plugin_locale),
\'singular_name\' => __(\'Promotion Campaign\', $this->plugin_locale),
\'menu_name\' => __(\'All Campaigns\', $this->plugin_locale),
\'all_items\' => __(\'All Campaigns\', $this->plugin_locale),
\'edit_item\' => __(\'Edit Campaign\', $this->plugin_locale),
\'view_item\' => __(\'View Campaign\', $this->plugin_locale),
\'update_item\' => __(\'Update Campaign\', $this->plugin_locale),
\'add_new_item\' => __(\'Add New Promotion Campaign\', $this->plugin_locale),
\'new_item_name\' => __(\'New Campaign Name\', $this->plugin_locale),
\'parent_item\' => __(\'Post parent:\', $this->plugin_locale),
\'parent_item_colon\' => __(\'Post parent:\', $this->plugin_locale),
\'search_items\' => __(\'Search Campaigns\', $this->plugin_locale),
\'add_or_remove_items\' => __(\'Add or Remove Campaigns\', $this->plugin_locale)
),
\'public\' => true,
\'show_ui\' => true,
\'show_in_nav_menus\' => false,
\'show_tagcloud\' => false,
\'show_admin_column\' => true,
\'hierarchical\' => true,
\'query_var\' => true,
\'rewrite\' => array(
\'slug\' => __(\'promotion\', $this->plugin_locale)
)
));
我还创建了一个名为
taxonomy-mfg_pp
, 这是分类法的名称,但它从不输出任何帖子,即使有帖子。罪魁祸首似乎是执行的WP\\U查询只查找帖子、页面和附件,如下所示:
SELECT SQL_CALC_FOUND_ROWS qADrathuFrU2_posts.ID FROM qADrathuFrU2_posts INNER JOIN qADrathuFrU2_term_relationships ON (qADrathuFrU2_posts.ID = qADrathuFrU2_term_relationships.object_id) WHERE 1=1 AND ( qADrathuFrU2_term_relationships.term_taxonomy_id IN (1196) ) AND qADrathuFrU2_posts.post_type IN (\'post\', \'page\', \'attachment\') AND (qADrathuFrU2_posts.post_status = \'publish\' OR qADrathuFrU2_posts.post_author = 1 AND qADrathuFrU2_posts.post_status = \'private\') AND qADrathuFrU2_posts.post_password = \'\' GROUP BY qADrathuFrU2_posts.ID ORDER BY qADrathuFrU2_posts.post_date DESC LIMIT 0, 10
我是不是做错了什么,我是不是走错了路?
请帮帮我,因为最后期限快到了,我似乎做不好!
提前谢谢你Jonathan