我正在尝试为现有自定义帖子类型启用修订。因为帖子类型大约在2年前就已经创建了,所以我在帖子类型是register的地方添加了revisions
到supports
大堆
之前我的代码是:
$labels = array(
\'name\' => \'Products\',
\'singular_name\' => \'Product\',
\'all_items\' => \'All Products\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Product\',
\'edit_item\' => \'Edit Products\',
\'new_item\' => \'New Product\',
\'view_item\' => \'View Product\',
\'search_items\' => \'Search Products\',
\'not_found\' => \'No Prducsts Found\',
\'not_found_in_trash\' => \'No Products in Trash\',
\'parent_item_colon\' => \'\'
);
$supports = array(
\'title\',
\'custom-fields\',
\'editor\',
\'thumbnail\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'menu_position\' => 5,
\'rewrite\' => array( \'slug\' => \'products\' ),
\'has_archive\' => true,
\'supports\' => $supports
);
register_post_type(\'products\', $args);
现在看起来:
$labels = array(
\'name\' => \'Products\',
\'singular_name\' => \'Product\',
\'all_items\' => \'All Products\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Product\',
\'edit_item\' => \'Edit Products\',
\'new_item\' => \'New Product\',
\'view_item\' => \'View Product\',
\'search_items\' => \'Search Products\',
\'not_found\' => \'No Prducsts Found\',
\'not_found_in_trash\' => \'No Products in Trash\',
\'parent_item_colon\' => \'\'
);
$supports = array(
\'title\',
\'custom-fields\',
\'editor\',
\'thumbnail\',
\'revisions\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'menu_position\' => 5,
\'rewrite\' => array( \'slug\' => \'products\' ),
\'has_archive\' => true,
\'supports\' => $supports
);
register_post_type(\'products\', $args);
此代码未启用自定义帖子类型中的修订。
然后我找到了另一个代码,我把它添加到了我的主题函数中。php:
function add_revisions_custom_post()
{
add_post_type_support( \'products\', \'revisions\' );
}
add_action(\'init\',\'add_revisions_custom_post\');
这个也不起作用。
有人能建议我如何启用修订吗?
提前谢谢。
EDIT:这是我的wp配置。php文件。
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don\'t have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* @package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define(\'WP_MEMORY_LIMIT\', \'64MB\');
define(\'DB_NAME\', \'MYDBNAME\');
/** MySQL database username */
define(\'DB_USER\', \'MYDBUSER\');
/** MySQL database password */
define(\'DB_PASSWORD\', \'MYDBPASSWORD\');
/** MySQL hostname */
define(\'DB_HOST\', \'localhost\');
/** Database Charset to use in creating database tables. */
define(\'DB_CHARSET\', \'utf8\');
/** The Database Collate type. Don\'t change this if in doubt. */
define(\'DB_COLLATE\', \'\');
define(\'WP_MEMORY_LIMIT\', \'64MB\');
/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define(\'AUTH_KEY\', \'c7ypbekexsfbt4wiucppwewene93cbtcfhf6xgpggepycabhildsoyqpre5iv3wi\');
define(\'SECURE_AUTH_KEY\', \'ujjxufvylpndsj0qeuwa90gxawj3cgaqnyusrdbmujmb08r37pnyreorpcyxqouu\');
define(\'LOGGED_IN_KEY\', \'vwlhlmenthgrq9g5jcocihz4ndldhrpegmcp6qyb3rfmjvxjejbacv1zharaexlp\');
define(\'NONCE_KEY\', \'qhnyqgmqckh3ylasveugagqlvifiuqajl6s9e7ulfrxepdxh2mewr8qhdinua8o2\');
define(\'AUTH_SALT\', \'rlb723gcatjvkfrd3jscmvdjio3kx9apm5yie9e4ibxktnnlukvgfpgbdsohrns9\');
define(\'SECURE_AUTH_SALT\', \'pllenyye8zbtml91hekptc2clqr7bhvhlriecz5qozexfhiqptmcvxrlehj44c16\');
define(\'LOGGED_IN_SALT\', \'9lyqc6qod0zdgyh6esp7bsxmpmuyp3h64m62pcnwxyefejh6tjykm7tpxhecg3xy\');
define(\'NONCE_SALT\', \'ob0bq3fye46rubbgu5flycjuai4ygxqgxho8bb1k8t81mwhghcbkysrgxrjzx0fu\');
/**#@-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each a unique
* prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = \'wp_\';
/**
* WordPress Localized Language, defaults to English.
*
* Change this to localize WordPress. A corresponding MO file for the chosen
* language must be installed to wp-content/languages. For example, install
* de_DE.mo to wp-content/languages and set WPLANG to \'de_DE\' to enable German
* language support.
*/
define (\'WPLANG\', \'\');
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*/
define(\'WP_DEBUG\', false);
/* That\'s all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined(\'ABSPATH\') )
define(\'ABSPATH\', dirname(__FILE__) . \'/\');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . \'wp-settings.php\');