我需要更改插件,创建/编辑条目到wp_posts表。目前缺乏它不能针对某些特定领域的问题。我正在努力编辑插件,以便我可以使用插件更改这些字段。下面的细节。如何在WordPress中从插件php编辑mySQL wp_posts表?
我通常会如何创建/编辑条目?
我心里有这样的事情,这是从here复制:
$my_post = array(
'post_title' => '#Enter the title#',
'post_content' => '#Enter the Content#',
'post_status' => 'publish',
'post_author' => 1
);
wp_insert_post($my_post);
我想这是可能的,因为我希望改变已经插件使更改wp_posts表。我该怎么做呢?我在C#中有编程经验,但我的PHP和WP知识严重缺乏。我假设我正在寻找一些WordPress key functions,但我根本不知道它们是什么或如何找到它们(我可能会搜索错误的术语)。 wp_insert_post()
看起来很有希望,但the documentation似乎暗示它不适合我的特定需求。
具体细节我使用了一个名为Really Simple CSV importer(RSC)的优秀插件,它允许您使用CSV创建/更新帖子
。它似乎能够瞄准几乎每个领域(例如,post_title
,post_id
,post_parent
,post_content
,_wp_page_template
等)。如果你必须定期创建数百页(这是我的),这是非常有益的。
问题是它不会针对标题为group_access
和tag_list
的两个特定字段。我把这些字段作为列放在我的csv中,但它们没有添加到mySQL数据库中,因此在网站上没有更改。我相信这些字段特定于名为iMember360的插件,该插件是一个与InfusionSoft帐户关联的插件。
当然,我已经尝试联系RSC支持,但没有收到任何回复。我已经和iMember360支持进行了长时间的对话,并且他们可以给我的最好的结果是他们使用动作钩import_end
来更改表格,所以如果RSC没有使用它,那么它不会影响这些领域。他们还说iMember360具有导入/导出功能,但它仅用于插件的特定功能,并且与WordPress XML导入/导出功能相关。显然,这个RSC插件不会那样做。
无论这些限制如何,在我看来,如果该字段存在于表格中,那么您应该可以对其进行编辑,所以我倾向于认为RSC插件完全缺乏此功能,可能只是定位只有WP默认字段。
我已经试过什么:
我曾尝试直接编辑插件PHP,并假设该插件根本没有对group_access
和tag_list
领域的条目。
一个PHP文件包含:
// (string, comma separated) name of post tags
$post_tags = $h->get_data($this,$data,'post_tags');
if ($post_tags) {
$post['post_tags'] = $post_tags;
}
我只是复制并粘贴它正上方,改变post_tags
至group_access
。它没有工作。
我还发现,并添加到:
$attachment = array(
'post_mime_type' => $mime_type ,
'post_parent' => $this->postid ,
'post_author' => $this->post->post_author ,
'post_title' => $title ,
'post_content' => $content ,
'post_excerpt' => $excerpt ,
'post_status' => 'inherit',
'menu_order' => $this->media_count + 1,
////////// added
'group_access' => $group_access ,
'tag_list' => $tag_list ,
//////
);
这并没有做任何事情无论是。