下面是一个如何使用\'registered_post_type\'
筛选以修改其他插件中的帖子类型。
我使用的插件在其定义中没有包含menu\\u图标,所以我想添加一个自己的插件。
<?php
/**
* Add a menu icon to the WP-VeriteCo Timeline CPT
*
* The timeline plugin doesn\'t have a menu icon, so we hook into \'registered_post_type\'
* and add our own.
*
* @param string $post_type the name of the post type
* @param object $args the post type args
*/
function wpse_65075_modify_timeline_menu_icon( $post_type, $args ) {
// Make sure we\'re only editing the post type we want
if ( \'timeline\' != $post_type )
return;
// Set menu icon
$args->menu_icon = get_stylesheet_directory_uri() . \'/img/admin/menu-timeline.png\';
// Modify post type object
global $wp_post_types;
$wp_post_types[$post_type] = $args;
}
add_action( \'registered_post_type\', \'wpse_65075_modify_timeline_menu_icon\', 10, 2 );