sagar290 / alpine-custom-post
这个库可以非常容易且高效地创建WordPress自定义文章类型。
dev-master
2022-01-18 09:25 UTC
Requires
- php: ^5.6|^7.2|^8.0
This package is auto-updated.
Last update: 2024-09-18 14:45:58 UTC
README
这个类可以帮助你在一秒内创建自定义文章类型。无需担心所有那些注册自定义文章的WordPress API函数,只需给出你的文章类型名称,BOOM!
示例
$book = new AlpineCustomPost("book");
看看结果 😃
安装
composer require sagar290/alpine-custom-post:dev-master
文档
基础
namespace Sagar290\CustomPost\AlpineCustomPost; $book = new AlpineCustomPost("book");
带自定义标签和参数
$labels = [ 'name' => _x($plural, 'post type general name'), 'singular_name' => _x($name, 'post type singular name'), 'add_new' => _x('Add New', strtolower($name)), 'add_new_item' => __('Add New ' . $name), 'edit_item' => __('Edit ' . $name), 'new_item' => __('New ' . $name), 'all_items' => __('All ' . $plural), 'view_item' => __('View ' . $name), 'search_items' => __('Search ' . $plural), 'not_found' => __('No ' . strtolower($plural) . ' found'), 'not_found_in_trash' => __('No ' . strtolower($plural) . ' found in Trash'), 'parent_item_colon' => '', 'menu_name' => $plural ]; $args = [ 'label' => $plural, 'labels' => $labels, 'public' => true, 'show_ui' => true, 'supports' => array('title', 'editor'), 'show_in_nav_menus' => true, '_builtin' => false, ]; $book = new AlpineCustomPost("book", $args, $labels);
额外功能
一些额外的功能,会让你的生活更加美好。
添加列
你也可以在edit.php页面上添加自定义列
$book->add_column("price", "callback"); function callback( $column, $post_id ) { if ( 'price' === $column ) { echo "your price here"; } }
结论
我创建这个类是为了我的个人项目。你也可以将其用于你的个人项目或开发。
最后但同样重要的是
由于我是一个新手开发者,犯错误是正常的。如果有任何问题,请随时提出,同时也欢迎提供贡献。