Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress wp_insert_post的页面内容功能_Wordpress - Fatal编程技术网

Wordpress wp_insert_post的页面内容功能

Wordpress wp_insert_post的页面内容功能,wordpress,Wordpress,我想在页面内容中添加用户名和密码两个文本字段。基本上我是在制作我的插件。我已经做了一个网页,这是连接到我的插件。我想使用函数在这个页面中添加内容 我的页面代码是: register_activation_hook( __FILE__, 'my_plugin_install_function'); function my_plugin_install_function() { $post = array( 'page_template' => '',

我想在页面内容中添加用户名和密码两个文本字段。基本上我是在制作我的插件。我已经做了一个网页,这是连接到我的插件。我想使用函数在这个页面中添加内容

我的页面代码是:

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的插件文件中,最好的方法是什么?

添加我没有使用的内容功能。但是我使用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>'; 

我知道这篇文章是5年前写的,但我现在正在尝试做一个wordpress插件,我找到了一个在wordpress中向自定义页面添加内容的解决方案,我所做的是创建一个包含所有内容的.php文件,包括php代码,然后通过创建一个变量并将该文件添加到包含file_get_内容的变量中,将该代码包含在我的post_type页面中,如下所示:


希望它有用

Ok,现在您的函数已经可读了。你有什么问题吗?请把
“post\u content”=>“post content”
?谢谢你的回复。我想这样做=>'post_content'->'myfunction()here'但是你试过这样做吗?
myfunction()
能做什么?你能给我facebook id或电子邮件吗。我可以在那里解释我所有的问题。请把问题解释清楚。欢迎来到StackOverflow。请不要将图像用于文本中易于传达的信息。图像对搜索、复制和粘贴或视力受损的人不友好。
'post_content'=> $form