I am trying to enable revisions for an existing custom post type. As the post type was already created about 2 years ago so where the post type was register I added revisions
to the supports
array.
Earlier my code was like:
$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);
And now it looks like:
$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);
This code didn’t enable revisions in the custom post type.
Then I found another code which I added to my theme’s function.php:
function add_revisions_custom_post()
{
add_post_type_support( 'products', 'revisions' );
}
add_action('init','add_revisions_custom_post');
This one is also not working.
Can anyone suggest me how I can enable revisions?
Thanks in advance.
EDIT:
Here is my wp-config.php file.
<?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');