简体   繁体   English

获取特定帖子类型的标签

[英]Get tags for a specific post type

I'm trying to query the WordPress database to get the post tags for a specific post type. 我正在尝试查询WordPress数据库以获取特定帖子类型的帖子标签。

So far I have this, which is giving me all the tags, but I'm not sure how to limit this to a specific post type, or if that is possible. 到目前为止,我已经有了它,为我提供了所有标签,但是我不确定如何将其限制为特定的帖子类型,或者是否可行。

$query = "SELECT name FROM wp_terms";
$myrows = $wpdb->get_results( $query );

foreach ( $myrows as $myrow ) 
{
    print_r($myrow);
}

In order to limit your queries, you can use the WHERE clause, ie 为了限制您的查询,您可以使用WHERE子句,即

$query = "SELECT name FROM wp_terms WHERE *post_type*=*typeyouwant*";

It's also possible to use the LIKE clause, but that results in very slow queries. 也可以使用LIKE子句,但这会导致查询非常慢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM