【发布时间】:2014-05-07 14:29:14
【问题描述】:
我正在尝试创建一个 wordpress twitter 插件,对于我的选项页面,我需要将表单保存到我设法创建的表中。我已经创建了表格,现在我需要知道如何确保它发布到我的表格中?我有以下代码,我的表名是 wp_twitter_carla。
function register_mysettings() {
//register our settings
register_setting( 'twitter-settings-group', 'twitteruser' );
register_setting( 'twitter-settings-group', 'notweets' );
register_setting( 'twitter-settings-group', 'replies' );
register_setting( 'twitter-settings-group', 'retweets' );
}
function twitter_settings_page() {
?>
<div class="wrap">
<h2>Twitter Feed by Carla</h2>
<form method="post" action="options.php">
<?php settings_fields( 'twitter-settings-group' ); ?>
<?php do_settings_sections( 'twitter-settings-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">Twitter Username</th>
<td><input type="text" name="twitteruser" value="<?php echo get_option('twitteruser'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Number of tweets to show</th>
<td><input type="text" name="notweets" value="<?php echo get_option('notweets'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Show replies?</th>
<td><input type="text" name="replies" value="<?php echo get_option('replies'); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row">Show retweets?</th>
<td><input type="text" name="retweets" value="<?php echo get_option('retweets'); ?>" /></td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
【问题讨论】:
-
当您注册一个设置时,它会转到表
wp_options。您不需要自己的表格来仅保存这 4 个选项...我认为您的意图是将实际的推文保存在表格中,不是吗?