[英]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.