[英]Custom form on WordPress blog
我想為我的WordPress博客創建一個自定義表單,該表單將使用用戶的電子郵件地址,然后將其添加到數據庫中。 我知道如何編寫表格和腳本來實現數據存儲。 我不知道如何將其粘貼在WordPress博客上。
是否有用於此類事情的插件,或者有什么方法可以手動將表單添加到頁面?
基本上,它是通知框的注冊。
謝謝。
如果您的主題已准備就緒,則可以使用文本窗口小部件添加它
在外觀下查看>小部件您可以將html添加到文本小部件
如果您使用的不是HTML,則小部件會遇到問題。 建議您自己創建一個小部件。
這是空白插件的代碼。 在“窗口小部件”功能中添加/調用您的代碼。
<?php
/*
Plugin Name: Blank Plugin
Plugin URI: http://www.example.com/plugins/blankPlugin/
Description: This is a plugin template
Author: Your Name
Version: 0.1
Author URI: http://www.example.com/about/
*/
class blankPlugin extends WP_Widget {
function blankPlugin() { // The widget construct. Initiating our plugin data.
$widgetData = array( 'classname' => 'blankPlugin', 'description' => __( "A blank plugin widget" ) );
$this->WP_Widget('blankPlugin', __('Blank Plugin'), $widgetData);
}
function widget($args, $instance) { // Displays the widget on the screen.
extract($args);
echo $before_widget;
echo $before_title . $instance['title'] . $after_title;
echo 'The amount is: '.$instance['amount'];
echo $after_widget;
}
function update($new_instance, $old_instance) { // Updates the settings.
return $new_instance;
}
function form($instance) { // The admin form.
$defaults = array( 'title' => 'Wichita', 'amount' => '45' );
$instance = wp_parse_args($instance, $defaults); ?>
<div id="blankPlugin-admin-panel">
<p>
<label for="<?php echo $this->get_field_id("title"); ?>">Widget title:</label>
<input type="text" class="widefat" name="<?php echo $this->get_field_name("title"); ?>" id="<?php echo $this->get_field_id("title"); ?>" value="<?php echo $instance["title"]; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id("amount"); ?>">An amount:</label>
<input type="text" class="widefat" name="<?php echo $this->get_field_name("amount"); ?>" id="<?php echo $this->get_field_id("amount"); ?>" value="<?php echo $instance["amount"]; ?>" />
</p>
</div>
<?php }
}
// Register the widget.
add_action('widgets_init', create_function('', 'return register_widget("blankPlugin");'));
?>
有關更多信息...(另請參見頁面底部的鏈接) http://codex.wordpress.org/Widgets_API#Developing_Widgets
您可以使用此wordpress插件http://wordpress.org/extend/plugins/contact-form-7/
或者可以根據自己的情況做。
您可以在主題文件夾中創建一個模板,如下所示:-
<?php
/*Template Name: some thing*/
//your dynamic stuff here
?>
並且可以將此模板分配給您的靜態頁面,您可以從wordpress的管理面板中創建該頁面。 只要您點擊此靜態頁面的超鏈接,該文件就會被調用。 因此,您可以處理所有郵件內容等。謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.