自定义wp发布功能
问题描述:
我不打算实现所有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的结构)
答
我觉得这是我的问题是:
$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
答
你已经有了:
in ('$newq')
基于您的代码,你可能结束了喜欢的:
in ('tag1,tag2,tag3')
,而不是需要和期望:
in ('tag1','tag2','tag3')
“我不是在WordPress的环境中工作,但利用wordpress结构“ - 祝你好运! :-) – 2011-05-27 06:40:02