PHP 自定义屏幕示例(向wordpress管理员添加新菜单)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 自定义屏幕示例(向wordpress管理员添加新菜单)相关的知识,希望对你有一定的参考价值。

// in theme/functions.php

add_action('init', 'jtd_custom_post_types');
function jtd_custom_post_types() {
	$labels = array(
	'name' => _x('Cards', 'post type general name'),
	'singular_name' => _x('Card', 'post type singular name'),
	'add_new' => _x('Add New', 'card'),
	'add_new_item' => __('Add New Card'),
	'edit_item' => __('Edit Card'),
	'new_item' => __('New Card'),
	'view_item' => __('View Card'),
	'search_items' => __('Search Cards'),
	'not_found' =>  __('No cards found'),
	'not_found_in_trash' => __('No cards found in Trash'),
	'parent_item_colon' => ''
	);
	$args = array(
	'labels' => $labels,
	'menu_position' => 30,
	'public' => true,
	'query_var' => true,
	'supports' => array( 'title', 'editor', 'comments', 'revisions', 'author', 'excerpt', 'custom-fields', 'page-attributes', 'thumbnail' ),
	'rewrite' => array( 'slug' => 'provider', 'with_front' => false ),
	'taxonomies' => array( 'post_tag', 'category'),

	);
	register_post_type('card',$args);
};

// This function tells WP to add a new "meta box"
function add_some_box() {
	add_meta_box(
		'ozh', // id of the <div> we'll add
		'My Box', //title
		'add_something_in_the_box', // callback function that will echo the box content
		'card' // where to add the box: on "post", "page", or "link" page
	);
}
// This function echoes the content of our meta box
function add_something_in_the_box() {
	echo "I'm living in a box";
}
// Hook things in, late enough so that add_meta_box() is defined
if (is_admin())
	add_action('admin_menu', 'add_some_box');

以上是关于PHP 自定义屏幕示例(向wordpress管理员添加新菜单)的主要内容,如果未能解决你的问题,请参考以下文章

php WordPress中自定义标题功能的示例实现。

PHP Wordpress - 自定义循环SQL查询(和热门帖子示例)

php [WordPress]自定义WordPress管理菜单(用户体验)

PHP Wordpress自定义管理员徽标

php 将自定义CSS应用于WordPress管理员

php 自定义管理页脚wordpress