【插件注释】:
~~~
<?php
/**
*Plugin Name: Basic Plugin
*Plugin URI:
*Author: Neo
*Author URI:
*Version: 1.1
*License: GPLv2
*/
~~~
如图所示:
![](https://box.kancloud.cn/1b8d0f8f85ebdca054ac81ae1a8af124_604x72.png)
【当前窗口弹出的链接】:
~~~
<?php
/**
*Plugin Name: Basic Plugin
*Plugin URI:
*Author: Neo
*Author URI:
*Version: 1.1
*License: GPLv2
*/
function dwwp_add_google_link() {
global $wp_admin_bar;
$wp_admin_bar->add_menu(array(
'id'=> 'google_analytics',
'title' => 'Google Analytics',
'href' => 'http://google.com/analytics',
'target' => ''
));
}
add_action('wp_before_admin_bar_render', 'dwwp_add_google_link');
~~~
如图所示:
![](https://box.kancloud.cn/bfaf3e34c415ebbf05249fd7963deb82_252x37.png)
【Book Post Type】
~~~
<?php
/**
*Plugin Name: Book Post Type
*Plugin URI:
*Author: Neo
*Author URI:
*Version: 1.1
*License: GPLv2
*/
//book post type
function cptui_register_my_cpts_book() {
/**
* Post Type: book.
*/
$labels = array(
"name" => __( "book", "twentyseventeen" ),
"singular_name" => __( "book", "twentyseventeen" ),
"menu_name" => __( "book", "twentyseventeen" ),
);
$args = array(
"label" => __( "book", "twentyseventeen" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => false,
"rest_base" => "",
"has_archive" => false,
"show_in_menu" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => array( "slug" => "book", "with_front" => true ),
"menu_icon" =>"dashicons-welcome-write-blog",
"query_var" => true,
"supports" => array( "title", "editor", "thumbnail", "excerpt", "trackbacks", "custom-fields", "comments", "revisions", "author", "page-attributes", "post-formats" ),
"taxonomies" => array( "category", "post_tag" ),
);
register_post_type( "book", $args );
}
add_action( 'init', 'cptui_register_my_cpts_book' );
~~~
如图所示:
![](https://box.kancloud.cn/064c4817a2381fe7d5b686e6259b0c48_464x303.png)
【参考】:
wordpress menu_icon:
<a href="https://developer.wordpress.org/resource/dashicons/#welcome-write-blog" target="_blank">https://developer.wordpress.org/resource/dashicons/#welcome-write-blog</a>
- WordPress平台的网站开发
- 电商主题开发
- WooCommerce主题开发优化部分
- 首页开发
- WooCommerce
- 判断用户是否登录
- WordPress Menu
- WooCommerce PayPal Checkout Gateway
- 页面和文章
- 调用产品和文章
- 判断属于哪个页面
- 相关文章
- 消除文章分享按钮集底部的文字
- wordpress主题模板和主题开发
- wordpress主题准备
- wordpress主题文件结构
- 豪源主题
- WooCommerce SEO
- 插件开发
- wordpress二次开发
- theme基本显示
- menu调用
- 分拆为header.php和footer.php
- 页面、文章样式选择显示
- 面包屑导航 Breadcrumb
- 特色图
- 阅读次数统计
- 分页功能
- Advanced Custom Fields
- Custom Post Type UI
- post type
- 小工具
- 小工具调用
- shortcode
- 文章循环输出
- 标题和文章限制字数输出显示
- WordPress主題theme1开发
- wordpress搭建多站点
- wordpress常用函數
- wordpress循环代码
- Woocommerce
- Woocommerce支持
- WordPress插件开发
- wordpress会员插件
- WordPress插件使用
- WordPress插件集
- WordPress的核心
- Wordpress原理
- Wordpress要点
- WordPress网站搬家
- WPML
- 服务器
- Cloud 9
- test
- 网站