moxie-lean / wp-cpt
更轻松地创建自定义文章类型。
1.0.4
2021-12-16 15:46 UTC
Requires
- php: >=7.2 || >=8.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-22 00:46:33 UTC
README
这个库将允许你轻松地为WordPress创建自定义文章类型,而无需太多努力。
安装
通过终端使用Composer安装此包是最简单的方法
composer require wearenolte/wp-cpt
或者通过在你的composer.json文件中添加以下行
"require": { "wearenolte/wp-cpt": "dev-master" }
这将从Packagist网站下载文件,并从存储库的master分支中获取最新版本。
之后,你可能需要包含autoload.php文件,以便在对象创建过程中自动加载类。
include '/vendor/autoload.php';
然后,你只需要创建一个新的Cpt对象,并使用你自定义文章类型的所需参数,如果你在主题中使用此库,你可能需要在init操作中添加函数,例如
add_action( 'init', function() { $testimonials = new \Lean\Cpt([ 'singular' => 'Testimonial', 'plural' => 'Testimonials', 'post_type' => 'testimonials', 'slug' => 'testimonial', ]); $testimonials->init(); });
上面的示例允许你在主题中创建一个新的见证文章类型。