atamj/wp-custom-post

一个类,让您轻松创建自定义文章

v1.0.0 2022-03-25 17:13 UTC

This package is auto-updated.

Last update: 2024-09-26 04:31:30 UTC


README

一个类,让您轻松创建自定义文章

参数

/**
 * @param string $post_type     Post type key. Must not exceed 20 characters and may only contain lowercase alphanumeric characters, dashes, and underscores.
 * @param string $menu_name     Name of the post type shown in the menu. Usually plural. Default is value of $labels['name']. Also used for $args['label'].
 * @param array $supports       Core feature(s) the post type supports (['title', 'editor', 'comments', 'revisions', 'trackbacks', 'author', 'excerpt', 'page-attributes', 'thumbnail', 'custom-fields', 'post-formats']). Default all support. Used for $args['supports'].
 * @param array $args           (Optional) Array of arguments for registering a post type.Dafault $args = ['has_archive'=>true, 'public'=>true, 'exclude_from_search'=>true, 'rewrite'=>$menu_name]. See https://developer.wordpress.org/reference/functions/register_post_type
 */

所有支持和最佳默认参数的示例

 new CustomPost('test', 'Tests');

自定义支持和最佳默认参数的示例

new CustomPost('test', 'Tests', ['title', 'editor', 'thumbnail', 'custom-fields'])

自定义支持和自定义参数的示例

new CustomPost('test', 'Tests', ['title', 'editor', 'thumbnail', 'custom-fields'], ['exclude_from_search'=>false])