我想在页面内容中添加两个用户名和密码的文本字段。基本上我正在制作我的插件。我创建了一个连接到我的插件的页面。我想通过使用函数在此页面中添加内容。
我的网页代码是:
register_activation_hook( __FILE__, 'my_plugin_install_function');
function my_plugin_install_function() {
$post = array(
'page_template' => '',
'comment_status' => 'closed',
'ping_status' => 'closed' ,
'post_author' => 1,
'post_date' => date('Y-m-d H:i:s'),
'post_name' => 'Checklists',
'post_status' => 'publish' ,
'post_title' => 'Checklists',
'post_type' => 'page',
'post_content' => 'my_function()'
);//insert page and save the id
$newvalue = wp_insert_post( $post, false ); //save the id in the database
update_option( 'hclpage', $newvalue );
}
my_function()
{
// A login form will be here.
}
有可能???什么是在wordpress ???
的插件文件中执行此操作的最佳方法答案 0 :(得分:0)
添加内容我没有使用功能。但我使用php变量。
$form = '<form action="..../wp-content/plugins/wp-link-with-parse/php-sdk/test.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<div id="lower">
<input type="submit" name="login" value="Login">
</form>';
分配内容使用:
'post_content'=> $form
答案 1 :(得分:-1)
我知道这篇文章来自5年前,但是我目前正在尝试制作wordpress插件,并且我找到了一种在wordpress中向自定义页面添加内容的解决方案,我所做的就是创建一个.php文件包含所有内容,包括php代码,然后通过创建变量并将该文件添加到具有file_get_contents的变量中,将该代码包含在我的post_type页面中,如下所示: enter image description here
希望它会有用