2011-12-10 5 views
0

이 코드를 사용하여 게시글을 업데이트했습니다. $x = wp_update_post($post); 그러나 정보를 전혀 업데이트하지 않습니다. 다음은 함수에 전송 된 $ post 배열의 내용입니다. 여기에서 582가 돌아오고 있으므로 성공합니다. 이 일을하는 다른 방법이 있는지 모르겠습니다. 일부 맞춤 게시물 메타가 있으며 게시물 유형은 맞춤 사진입니다.WordPress 업데이트가 사용자 정의 게시 유형에서 작동하지 않는 이유

Array 
(
    [ID] => 582 
    [upload_title] => Flower Warriors 
    [upload_desc] => Aenean condimentum massa id leo ullamcorper 
    [upload_keywords] => Blog, Demo, Flower, Images 
    [upload_price] => 58 
    [extra_categories] => Array 
     (
      [0] => 6 
      [1] => 8 
      [2] => 10 
      [3] => 18 
      [4] => 19 
      [5] => 23 
     ) 

    [property_release] => 2 
    [release_info] => Tinterdum lacus eget hendrerit? Quisque a turpis sit amet est consequat vestibulum. 
    [large_price] => 39 
    [medium_price] => 18 
    [small_price] => 14 
) 

답변

0

wp_update_post는 사용자 지정 필드를 업데이트하지 않습니다. 이런 경우에는 다음과 같이해야합니다.

add_post_meta ($ id, 'upload_title', 'Flower Warriors', true) 또는 update_post_meta ($ id, 'upload_title', 'Flower Warriors');

가장 쉬운 방법은 별도의 변수에 사용자 정의 필드를 추가하고 foreach 루프를 실행하는 것입니다.

//$id is the ID of the post you're updating 
foreach ($cf as $k => $v) : 
    add_post_meta($id, $k, $v, true) or update_post_meta($id, $k, $v); 
endforeach; 
관련 문제