【问题标题】:wordpress add pagewordpress 添加页面
【发布时间】:2012-07-13 22:41:59
【问题描述】:

我正在为 wordpress 编写插件,管理员应该在这个插件中添加一些信息,例如 ===> 标题、数据库中的文本。

我希望将此信息作为 wordpress 页面添加到数据库中。

我应该使用什么函数来完成这个任务?

【问题讨论】:

    标签: wordpress plugins


    【解决方案1】:

    您可以使用wp_insert_post 来表示http://codex.wordpress.org/Function_Reference/wp_insert_post

    页面只是 WP 中的一种帖子。

    $post = array(
      'post_title' => 'my Title',
      'post_content' => 'my Text',
      'post_type' => 'page',
    
      'post_status' => 'publish',   
      'post_author' => 1
    );
    
    wp_insert_post( $post );
    

    【讨论】:

    猜你喜欢
    • 2014-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多