underpin / post-template-loader
Underpin 的文章模板加载器
1.1.0
2021-11-24 21:33 UTC
Requires
- underpin/underpin: ^2.0
This package is auto-updated.
Last update: 2024-08-25 03:06:48 UTC
README
一个帮助向 WordPress 网站添加文章模板的加载器。
安装
使用 Composer
composer require underpin/post-template-loader
手动安装
此插件使用内置的自动加载器,只要在 Underpin 之前安装,它应该可以按预期工作。
require_once(__DIR__ . '/underpin-post-templates/post-templates.php');
配置
- 安装 Underpin。请参阅Underpin 文档
- 根据需要注册新的文章模板。
示例
一个非常基础的例子可能看起来像这样。
\Underpin\underpin()->post_templates()->add( 'template', [ 'name' => 'Template Name', // Shows in dropdown 'template' => 'template-name' // Shows when post template is fetched, and in REST ] );
或者,您可以扩展 post template
并直接引用扩展类,如下所示
underpin()->post_templates()->add('key','Namespace\To\Class');