您可以创建自己选择的自定义帖子类型插件,您必须按照以下步骤创建自己选择的成功插件。
1. Step One:
您必须在
wp-content->plugins->YOUR PLUGIN FOLDER
.
(例如)-在我们的示例中,我们将创建名为Destination_Category
文件夹结构:wp-content->plugins->Destination_Category
.
2. Step Two:
在该文件夹中,您必须按如下方式创建文件结构。
css(文件夹)图像(文件夹)索引。php
3. Step Three:
打开索引。php,您必须添加插件的版权和说明。
在我们的示例中,我们将创建为目标类别。
<?php
/*
Plugin Name: Destination Category
Description: This plugin is used for the creation of the Custom Category for the Wordpress Destination Post type and it allows you to link the Category and the Sub Category using this plugin.
Version: 1.0
Author: Naresh Kumar.P
Email: [email protected]
License: NKPDC007
*/
?>
创建此结构后,您可以在
Plugins
WordPress仪表板上的菜单。您可以查看插件名称、描述、电子邮件和您提供的所有其他详细信息。
4. Step Four:
除了第三步,你还必须
register the custom post type
有了可用的代码,就可以使用所需的插件创建您。
//Creation of custom post type(Start)
add_action( \'init\', \'create_destination_category\' );
function create_destination_category()
{
$args = array(
\'labels\' => array(
\'name\' => \'Destination Categories\',
\'singular_name\' => \'Destination Category\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Destination Category\',
\'edit\' => \'Edit\',
\'edit_item\' => \'Edit Destination Category\',
\'new_item\' => \'New Destination Category\',
\'view\' => \'View\',
\'view_item\' => \'View Destination Category\',
\'search_items\' => \'Search Destination Category\',
\'not_found\' => \'No Destination Categories found\',
\'not_found_in_trash\' => \'No Destination Category found in Trash\',
),
\'menu_position\' => 15,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'custom-fields\' ),
\'menu_icon\' => plugins_url( \'images/logo.png\', __FILE__ ),
\'public\' => true
);
register_post_type( \'destination_category\',$args);
}//Creation of custom post type(End)
还有一步要做,那就是你现在要激活你创建的插件,你将得到如下消息
Your plugin is successfully activated
这样就成功创建了插件。
以及整个索引。php看起来像下面的代码。
index.php
<?php
/*
Plugin Name: Destination Category
Description: This plugin is used for the creation of the Custom Category for the Wordpress Destination Post type and it allows you to link the Category and the Sub Category using this plugin.
Version: 1.0
Author: Naresh Kumar.P
Email: [email protected]
License: NKPDC007
*/
//Creation of custom post type(Start)
add_action( \'init\', \'create_destination_category\' );
function create_destination_category()
{
$args = array(
\'labels\' => array(
\'name\' => \'Destination Categories\',
\'singular_name\' => \'Destination Category\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Destination Category\',
\'edit\' => \'Edit\',
\'edit_item\' => \'Edit Destination Category\',
\'new_item\' => \'New Destination Category\',
\'view\' => \'View\',
\'view_item\' => \'View Destination Category\',
\'search_items\' => \'Search Destination Category\',
\'not_found\' => \'No Destination Categories found\',
\'not_found_in_trash\' => \'No Destination Category found in Trash\',
),
\'menu_position\' => 15,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'custom-fields\' ),
\'menu_icon\' => plugins_url( \'images/logo.png\', __FILE__ ),
\'public\' => true
);
register_post_type( \'destination_category\',$args);
}//Creation of custom post type(End)
?>