Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从名称为“服务”的 wp_terms 获取类别 ID。我这样做:
$myrows = $wpdb-> query("SELECT * FROM wp_terms WHERE name='services' " ); if(!$myrows){ echo "wrong".mysql_error(); } else{ echo $myrows ->ID; }
但它不打印任何东西。这里有什么问题?
这取决于你想做什么,但你能试试这个吗?
echo get_cat_ID('services');
请参阅http://codex.wordpress.org/Function_Reference/get_cat_ID