有人已经问过了here, 但这并不能解决我的问题。
我的主题禁用自定义字段。如何手动启用它?我想知道Wordpress使用哪种代码来显示自定义字段小部件?请帮忙。
更新:实际上,这是一个教育主题,创建了一些新的发布选项,如“课程”、“课程”&;“证明”。我想把自定义字段带到那里。
Fuctions.php
:
<?php
//Error reporting
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
//Define constants
define(\'SITE_URL\', home_url().\'/\');
define(\'AJAX_URL\', admin_url(\'admin-ajax.php\'));
define(\'THEME_PATH\', get_template_directory().\'/\');
define(\'THEME_URI\', get_template_directory_uri().\'/\');
define(\'THEME_CSS_URI\', get_stylesheet_directory_uri().\'/\');
define(\'THEMEX_PATH\', THEME_PATH.\'framework/\');
define(\'THEMEX_URI\', THEME_URI.\'framework/\');
//Set content width
$content_width=1140;
//Load language files
load_theme_textdomain(\'academy\', THEME_PATH.\'languages\');
//Include theme functions
include(THEMEX_PATH.\'functions.php\');
//Include theme configuration file
include(THEMEX_PATH.\'config.php\');
//Include core class
include(THEMEX_PATH.\'classes/themex.core.php\');
//Init theme
$theme=new ThemexCore($config);
最合适的回答,由SO网友:brasofilo 整理而成
创建Child Theme, Plugin 或Must Use 插件,并使用add_post_type_support
:
<?php
/* Plugin Name: Add CF to CPTs */
add_action( \'plugins_loaded\', \'add_cpt_support_wpse_116891\' );
function add_cpt_support_wpse_116891(){
# See /wp-admin/edit.php?post_type=SLUG
add_post_type_support( \'SLUG-POST-TYPE-1\', array( \'custom-fields\' ) );
add_post_type_support( \'SLUG-POST-TYPE-2\', array( \'custom-fields\' ) );
add_post_type_support( \'SLUG-POST-TYPE-3\', array( \'custom-fields\' ) );
}