php代码错误(从头开始构建wordpress主题)
我从零开始关注书籍构建wordpress主题。通过wordpress管理面板中的此方法创建了一个选项页。存在一个错误,原因是其中没有显示任何内容 首先,它被添加到wordpress的functions.php中:php代码错误(从头开始构建wordpress主题),php,wordpress,function,Php,Wordpress,Function,我从零开始关注书籍构建wordpress主题。通过wordpress管理面板中的此方法创建了一个选项页。存在一个错误,原因是其中没有显示任何内容 首先,它被添加到wordpress的functions.php中: <?php require_once('theme-options.php'); ?> 其次,创建了theme-options.php,其中包含以下内容: <?php // create custom plugin settings menu add_acti
<?php require_once('theme-options.php'); ?>
其次,创建了theme-options.php,其中包含以下内容:
<?php
// create custom plugin settings menu
add_action('admin_menu', 'director_create_menu');
function director_create_menu() {
//create new submenu
add_submenu_page( 'themes.php', 'Director Theme Options',
'Director Options', 'administrator', __FILE__,
'wptuts_landing_settings_page');
//call register settings function
add_action( 'admin_init', 'director_register_settings' );
}
function director_register_settings() {
//register our settings
register_setting( 'director-settings-group', 'director_facebook' );
register_setting( 'director-settings-group', 'director_twitter' );
register_setting( 'director-settings-group', 'director_rss' );
register_setting( 'director-settings-group', 'director_logo' );
register_setting( 'director-settings-group', 'director_analytics' );
}
function director_settings_page() {
?>
<div class="wrap">
<h2>Director Theme Settings</h2>
<form id="landingOptions" method="post" action="options.php">
<?php settings_fields( 'director-settings-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Logo:</th>
<td>
<input type="text" name="director_logo" value="<?php print get_option('director_logo'); ?>" />
<br/>
</td>
</tr>
<tr valign="top">
<th scope="row">Facebook Link:</th>
<td>
<input type="text" name="director_facebook"
value="<?php print get_option('director_facebook');
?>" />
</td>
</tr>
<tr valign="top">
<th scope="row">Twitter Link:</th>
<td>
<input type="text" name="director_twitter" value="<?php print get_option('director_twitter'); ?>" />
</td>
</tr>
<tr>
<th scope="row">Display RSS Icon:</th>
<td>
<input type="checkbox" name="director_rss" <?php
if(get_option('director_rss') == true){ print
"checked"; } ?> />
</td>
</tr>
<tr>
<th scope="row">Google Analytics Code:</th>
<td>
<textarea name="director_analytics"><?php print
get_option('director_analytics'); ?></textarea>
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
</p>
</form>
</div>
<?php } ?>
导演主题设置
标志:
我找到了解决方案,并想为其他遇到问题的人发布
没有出现WordPress错误。但是问题是由于add_子菜单页面调用导致的,在该调用中,应该调用函数director\u settings\u page
,而不是wptuts\u landing\u settings\u page
,内部没有任何内容意味着您得到一个空HTML页面,一个空正文,根本没有结果?你能提供一个截图吗?@ZoolWay我已经附上了截图打开调试模式,看看你调用的是过时的语法还是调用。它在你的WP配置中,在底部。将DEBUG设置为true。