2011-05-27 86 views
2

我不打算實現所有wp_post功能。自定義wp發佈功能

的事情很感興趣(已給我的問題COS我沒有得到正確的關係)是插入和更新的值到 1.職位表 2.術語表 3. term_taxonomy 4的sql長期關係

表格發佈後。

$sql="update wp_posts set post_title='$name', post_name='$slug', post_content='$freeRTE_content', post_category='$category', post_status='$post_status', comment_status='$comment_status', mode_application='$howtoapply', website_address='$website', company_email='$email', application_deadline='$last_date', advert_date='$advert_date', post_date='$date', featured='$featured', course='$course', location='$location', grade='$grade' where id='$id'"; 
      if(mysql_query($sql, $link)) 
      { 
       $expq=explode(',' , $q);foreach($expq as $key=>$value){$expq[$key]=trim($value);}$newq=join(',',$expq); 
       $sql="insert into wp_term_relationships (term_taxonomy_id) select term_taxonomy_id from wp_term_taxonomy tt, wp_terms t where name in ('$newq') and taxonomy='post_tag' and t.term_id=tt.term_id"; 
       if(mysql_query($sql, $link)) 
       { 
        $sql="update wp_term_taxonomy tt, wp_terms t set count=count+1 where name in ('$newq') and taxonomy='post_tag' and t.term_id=tt.term_id"; 
        $result=mysql_query($sql, $link) or die(mysql_error($link)); 
       } 

      } 

     } 

我沒有得到正確的四張表之間的關係,請問我該如何解決這個問題?

(請我不是一個WordPress的環境中工作,但利用WordPress的結構)

+1

「我不是在WordPress的環境中工作,但利用wordpress結構「 - 祝你好運! :-) – 2011-05-27 06:40:02

回答

0

我覺得這是我的問題是:

$sql="insert into wp_term_relationships (term_taxonomy_id) select term_taxonomy_id from wp_term_taxonomy tt, wp_terms t where name in ('$newq') and taxonomy='post_tag' and t.term_id=tt.term_id"; 

正確的事情要做:

$sql="insert into wp_term_relationships (object_id, term_taxonomy_id) values ('my_post_id', 'the term taxonomy id')"; 

感謝所有

+0

這是問題的1,謝謝 – 2011-06-18 07:08:42

0

你已經有了:

in ('$newq') 

基於您的代碼,你可能結束了喜歡的:

in ('tag1,tag2,tag3') 

,而不是需要和期望:

in ('tag1','tag2','tag3')