【发布时间】:2017-07-24 00:09:06
【问题描述】:
我需要更改创建/编辑 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 ,
//////
);
那也没有用。
【问题讨论】:
标签: php mysql wordpress plugins