从插件生成的POST类型中获取寄存器_POST_TYPE的参数

时间:2019-04-11 作者:lomokev

我已经从另一个开发人员那里接管了这个网站,他们使用一个插件来生成自定义的帖子类型。该插件不再维护,并且在尝试加载插件管理页面时导致错误505。前端站点工作正常。

所以我想知道是否有任何方法可以获取用于register_post_type() 对于插件生成的帖子类型,这样就不必使用插件了?该插件仍然有效,只是它的课程和错误505插件管理页面,所有插件页面工作,但不幸的是,没有导出选项,可以用来给我参数register_post_type().

插件是Toolset Types 如果有帮助的话

1 个回复
最合适的回答,由SO网友:Qaisar Feroz 整理而成

所以我想知道是否有任何方法可以获取用于register_post_type 对于插件生成的帖子类型,这样就不必使用插件了?

您可以使用get_post_type_object( string $post_type ). 请参阅文档和示例用法here.

$obj = get_post_type_object( \'certification\' );

print_r( $obj ); 
上面的代码可能会返回类似的结果,因此您可以获取register_post_type ():

stdClass Object
(
    [labels] => stdClass Object
        (
            [name] => Certification
            [singular_name] => Certification
            [add_new] => Add New
            [add_new_item] => Add New Certification
            [edit_item] => Edit Certification
            [new_item] => New Page
            [view_item] => View Certification
            [search_items] => Search Certification
            [not_found] => Not found
            [not_found_in_trash] => Not found in Trash
            [parent_item_colon] => Parent Certification:
            [all_items] => All Certifications
            [menu_name] => Certifications
            [update_item] => Update Certification
            [name_admin_bar] => Certification
        )
    [description] => Certifications
    [public] => 1
    [hierarchical] => 1
    [exclude_from_search] => 
    [publicly_queryable] => 1
    [show_ui] => 1
    [show_in_menu] => 
    [show_in_nav_menus] => 1
    [show_in_admin_bar] => 1
    [menu_position] => 5
    [menu_icon] => dashicons-welcome-widgets-menus
    [capability_type] => post
    [map_meta_cap] => 1
    [register_meta_box_cb] => 
    [taxonomies] => Array
        (
            [0] => objective
        )
    [has_archive] => 1
    [rewrite] => Array
        (
            [slug] => certification
            [with_front] => 1
            [pages] => 1
            [feeds] => 1
            [ep_mask] => 1
        )
    [query_var] => certification
    [can_export] => 1
    [delete_with_user] => 
    [_builtin] => 
    [_edit_link] => post.php?post=%d
    [label] => Certification
    [name] => certification
    [cap] => stdClass Object
        (
            [edit_post] => edit_post
            [read_post] => read_post
            [delete_post] => delete_post
            [edit_posts] => edit_posts
            [edit_others_posts] => edit_others_posts
            [publish_posts] => publish_posts
            [read_private_posts] => read_private_posts
            [read] => read
            [delete_posts] => delete_posts
            [delete_private_posts] => delete_private_posts
            [delete_published_posts] => delete_published_posts
            [delete_others_posts] => delete_others_posts
            [edit_private_posts] => edit_private_posts
            [edit_published_posts] => edit_published_posts
            [create_posts] => edit_posts
        )
)
我希望这会有所帮助。

相关推荐

Testing Plugins for Multisite

我最近发布了一个WordPress插件,它在单个站点上非常有效。我被告知该插件在多站点安装上不能正常工作,我理解其中的一些原因。我已经更新了代码,现在需要一种方法来测试更新后的代码,然后才能转到实时客户的多站点安装。我有一个用于测试的WordPress安装程序的单站点安装,但需要在多站点安装上进行测试。根据我所能找到的唯一方法是在网络上至少有两个站点来安装整个多站点安装,以测试我的插件。设置WordPress的整个多站点安装是插件开发人员的唯一/首选方式,还是有更快的测试环境可用。