[英]How to create a query that return custom post type by Advanced Custom Field(ACF) Taxonony?
you all!你们!
I have categories of Author我有作者类别
I have categories of Books我有书籍类别
I have a custom post type Author.我有一个自定义帖子类型作者。 Author has custom fields:
作者有自定义字段:
I have a custom post type Book.我有一个自定义帖子类型书。 Book has custom fields:
书有自定义字段:
I need a query that return ALL BOOKs with Authors that have Contract ID = 1我需要一个查询,返回所有作者的合约 ID = 1 的书籍
And和
I need a query that return ALL BOOKs with Type = Fiction我需要一个查询,返回所有类型 = Fiction 的书籍
Thanks!!!谢谢!!!
You should use meta_query to get the desired results:您应该使用 meta_query 来获得所需的结果:
I need a query that return ALL BOOKs with Authors that have Contract ID = 1
我需要一个查询,返回所有作者的合约 ID = 1 的书籍
$freelance_books = get_posts(array(
'numberposts' => -1,
'post_type' => 'books',
'meta_key' => 'book_contract', // Adjust here with your field name
'meta_value' => 1
));
I need a query that return ALL BOOKs with Type = Fiction
我需要一个查询,返回所有类型 = Fiction 的书籍
$fiction_books = get_posts(array(
'numberposts' => -1,
'post_type' => 'books',
'meta_key' => 'book_type', // Adjust here with your field name
'meta_value' => 2
));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.