admin管理员组文章数量:1395752
I am developing a plugin for custom post type which take the link from the title of the post and then after scraping on that link it updates all things like post title, post permalink and post_meta. Now its only updating the title and the link but not the post meta, I have tried debugging the data.
function a_new_post($new_status, $old_status, $post)
{
if ('publish' !== $new_status or 'publish' === $old_status)
return;
$new_slug = sanitize_title($post->post_title);
if ('aps-products' !== $post->post_type)
return; // restrict the filter to a specific post type
$result= getSpecs($post->post_title);
/*
******************************************************************************
******************************************************************************
******************************************************************************
*/
$groups = get_aps_cat_groups(16);
$groups_data = get_aps_groups_data();
$attrs_data = get_aps_attributes_data();
// get aps attributes data from input fields
foreach ($groups as $groupId) {
$group_data = $groups_data[$groupId];
$group_values = get_aps_product_attributes($post->ID, $groupId);
if ($group_data['attrs']) {
if (aps_is_array($group_data['attrs'])) {
$first=array();
$value='';
foreach ($group_data['attrs'] as $attr_id) {
switch($attr_id){
case 20:
$value=$result[1];
break;
case 21:
$value=$result[12];
break;
case 22:
$value=$result[3];
break;
case 24:
$value=$result[13];
break;
}
$frist[$attr_id]=$value;
}
update_post_meta( $post->ID, 'aps-attr-group-' .$groupId, $first );
}
}
}
/*
******************************************************************************
******************************************************************************
******************************************************************************
*/
$post_update = array(
'ID' => $post->ID,
'post_title' => $result[0].' '.$result[1]
);
if (!wp_is_post_revision($post->ID)) {
wp_update_post($post_update);
$new_slug = sanitize_title($result[0].' '.$result[1]);
if ($post->post_name != $new_slug) {
wp_update_post(
array(
'ID' => $post->ID,
'post_name' => $new_slug
)
);
}
}
}
本文标签: plugin developmentUpdate post meta not working in transitionpoststatus
版权声明:本文标题:plugin development - Update post meta not working in transition_post_status 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744606230a2615371.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论