WP_Query($args) 在 Wordpress 中不起作用
Posted
技术标签:
【中文标题】WP_Query($args) 在 Wordpress 中不起作用【英文标题】:WP_Query($args) are not working in Wordpress 【发布时间】:2019-08-29 07:38:49 【问题描述】:我是 wordpress 的新手。我将自定义参数传递给 WP_Query 函数。其返回无效结果。我限制每页 10 的产品,但它显示所有产品。
$args - 打印结果
数组([post_type] => 产品 [posts_per_page] => 10 [post_status] => 发布 [paged] => 1 [orderby] => [order] => [meta_query] => Array ( [0] => 数组 ( ) ) [tax_query] => 数组 ( [0] => 数组 ( [分类] => product_cat [field] => slug [terms] => 数组 ([0] => 传统披萨 ) [运算符] => IN ) ) )
获取产品后
WP_Query 对象 ( [query] => 数组 ( [post_type] => 产品 [posts_per_page] => 20 [post_status] => 发布 [paged] => 0 [orderby] => [order] => [meta_query] => Array ( [0] => Array ( ) ) [tax_query] => Array ( [0] => Array ( [taxonomy] => product_cat [field] => slug [术语] => 数组 ( [0] => 传统披萨) [运算符] => IN ) ) [query_vars] => 数组([post_type] => 产品 [posts_per_page] => 999 [post_status] => 发布 [paged] => 0 [orderby] => [order] => DESC [meta_query] => 数组 ( [0] => 数组 ( ) ) [tax_query] => 数组 ( [0] => Array ( [taxonomy] => product_cat [field] => slug [terms] => Array ( [0] => traditional-pizza ) [operator] => IN ) ) [error] => [m] => [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [秒] => [分钟] => [小时] => [日] => 0 [月数] => 0 [年] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author] => [author_name] => [feed] => [tb] => [元键] => [meta_value] => [preview] => [s] => [sentence] => [title] => [fields] => [menu_order] => [embed] => [category__in] => 数组 ( ) [category__not_in] => 数组 ( ) [category__and] => 数组 ( ) [post__in] => 数组 () [post__not_in] => 数组 () [post_name__in] => 数组 ( ) [tag__in] => 数组 ( ) [tag__not_in] => 数组 ( ) [tag__and] => 数组 ( ) [tag_slug__in] => 数组 ( ) [tag_slug__and] => 数组 ( ) [post_parent__in] => 数组 ( ) [post_parent__not_in] => 数组 ( ) [作者__in] => 数组 ( ) [作者__not_in] => 数组 ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [lazy_load_term_meta] => 1 [update_post_meta_cache] => 1 [nopage] => [cmets_per_page] => 50 [no_found_rows] => [分类] => product_cat [term] => 传统披萨)[tax_query] => WP_Tax_Query 对象([查询] => 数组 ( [0] => 数组 ( [分类] => product_cat [terms] => 数组 ( [0] => 传统披萨) [字段] => slug [操作员] => IN [include_children] => 1 ) ) [relation] => AND [table_aliases:protected] => 数组([0] => wp_term_relationships) [queried_terms] => 数组 ( [product_cat] => 数组 ( [terms] => 数组 ( [0] => 传统披萨 ) [field] => slug ) ) [primary_table] => wp_posts [primary_id_column] => ID ) [meta_query] => WP_Meta_Query 对象([查询] => 数组()[关系] => AND [元表] => [meta_id_column] => [primary_table] => [primary_id_column] => [table_aliases:protected] => Array ( ) [clauses:protected] => Array ( ) [has_or_relation:protected] => ) [date_query] => [request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (48) ) AND wp_posts.post_type = '产品' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 999 [帖子] => 数组([0] => WP_Post 对象([ID] => 922 [post_author] => 1 [post_date] => 2019-03-14 20:29:12 [post_date_gmt] => 2019-03-14 20:29:12 [post_content] => [post_title] => 巧克力披萨 [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 巧克力披萨 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:18 [post_modified_gmt] => 2019-03-14 20:29:18 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-125/ [menu_order] => 25 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [1] => WP_Post Object ([ID] => 919 [post_author] => 1 [post_date] => 2019-03-14 20:29:10 [post_date_gmt] => 2019-03-14 20:29:10 [post_content] => 番茄、奶酪、鸡肉、菠萝配烧烤酱。 [post_title] => 烧烤 鸡 [post_excerpt] => [post_status] => 发布 [comment_status] => 已关闭 [ping_status] => 已关闭 [post_password] => [post_name] => 烧烤鸡 [to_ping] => [pinged] => [post_modified] => 2019-03-15 00:15:31 [post_modified_gmt] => 2019-03-15 00:15:31 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-122/ [menu_order] => 22 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [2] => WP_Post Object ([ID] => 920 [post_author] => 1 [post_date] => 2019-03-14 20:29:10 [post_date_gmt] => 2019-03-14 20:29:10 [post_content] => 番茄、奶酪、鸡肉、菠萝、培根、虾。 [post_title] => 鸡 ROYALE [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 皇家鸡 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:17 [post_modified_gmt] => 2019-03-14 20:29:17 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-123/ [menu_order] => 23 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [3] => WP_Post Object ([ID] => 921 [post_author] => 1 [post_date] => 2019-03-14 20:29:10 [post_date_gmt] => 2019-03-14 20:29:10 [post_content] => 番茄、奶酪、碎牛肉配洋葱和牛至。 [post_title] => 牛肉 PIZZA [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 牛肉比萨 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:18 [post_modified_gmt] => 2019-03-14 20:29:18 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-124/ [menu_order] => 24 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [4] => WP_Post Object ([ID] => 917 [post_author] => 1 [post_date] => 2019-03-14 20:29:09 [post_date_gmt] => 2019-03-14 20:29:09 [post_content] => 番茄、奶酪、火腿、蘑菇、辣椒、热意大利腊肠、墨西哥胡椒和辣椒。 [post_title] => VOLCANO [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 火山 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:17 [post_modified_gmt] => 2019-03-14 20:29:17 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-120/ [menu_order] => 20 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [5] => WP_Post Object ([ID] => 918 [post_author] => 1 [post_date] => 2019-03-14 20:29:09 [post_date_gmt] => 2019-03-14 20:29:09 [post_content] => 番茄、奶酪、蘑菇、鸡肉和大蒜。 [post_title] => 鸡 [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 鸡 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:17 [post_modified_gmt] => 2019-03-14 20:29:17 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-121/ [menu_order] => 21 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [6] => WP_Post Object ([ID] => 913 [post_author] => 1 [post_date] => 2019-03-14 20:29:08 [post_date_gmt] => 2019-03-14 20:29:08 [post_content] => 夏威夷、玛格丽塔、澳大利亚和肉类。 [post_title] => 四 季度 [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 四分之四 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:17 [post_modified_gmt] => 2019-03-14 20:29:17 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-116/ [menu_order] => 16 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [7] => WP_Post Object ([ID] => 914 [post_author] => 1 [post_date] => 2019-03-14 20:29:08 [post_date_gmt] => 2019-03-14 20:29:08 [post_content] => 番茄、奶酪、什锦海鲜与大蒜和牛至混合。 [post_title] => MARINARA [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => marinara [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:17 [post_modified_gmt] => 2019-03-14 20:29:17 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-117/ [menu_order] => 17 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [8] => WP_Post Object ([ID] => 915 [post_author] => 1 [post_date] => 2019-03-14 20:29:08 [post_date_gmt] => 2019-03-14 20:29:08 [post_content] => 番茄、奶酪、火腿、蘑菇、洋葱、辣椒、菠萝、橄榄、培根、意大利香肠、虾。 [post_title] => 很多 [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 关闭 [post_password] => [post_name] => the-lot [to_ping] => [pinged] => [post_modified] => 2019-03-15 00:16:15 [post_modified_gmt] => 2019-03-15 00:16:15 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-118/ [menu_order] => 18 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [9] => WP_Post Object ([ID] => 916 [post_author] => 1 [post_date] => 2019-03-14 20:29:08 [post_date_gmt] => 2019-03-14 20:29:08 [post_content] => 番茄、奶酪、火腿、蘑菇、洋葱、辣椒、热 意大利腊肠、培根、橄榄、辣椒和牛至。 [post_title] => HOUSE SPECIAL [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 关闭 [post_password] => [post_name] => 房子特别 [to_ping] => [pinged] => [post_modified] => 2019-03-15 00:16:42 [post_modified_gmt] => 2019-03-15 00:16:42 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-119/ [menu_order] => 19 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [10] => WP_Post Object ([ID] => 909 [post_author] => 1 [post_date] => 2019-03-14 20:29:07 [post_date_gmt] => 2019-03-14 20:29:07 [post_content] => 番茄、奶酪、橄榄、凤尾鱼和牛至。 [post_title] => 拿破仑 [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 关闭 [post_password] => [post_name] => napoletana [to_ping] => [pinged] => [post_modified] => 2019-03-25 15:09:19 [post_modified_gmt] => 2019-03-25 15:09:19 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-112/ [menu_order] => 12 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [11] => WP_Post Object ([ID] => 910 [post_author] => 1 [post_date] => 2019-03-14 20:29:07 [post_date_gmt] => 2019-03-14 20:29:07 [post_content] => 番茄、奶酪、大量培根蛋。 [post_title] => 鸡蛋和培根 [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 鸡蛋和培根 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:16 [post_modified_gmt] => 2019-03-14 20:29:16 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-113/ [menu_order] => 13 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [12] => WP_Post Object ([ID] => 911 [post_author] => 1 [post_date] => 2019-03-14 20:29:07 [post_date_gmt] => 2019-03-14 20:29:07 [post_content] => 番茄、奶酪、火腿、蘑菇、培根、虾和鸡蛋。 [post_title] => 超级 澳大利亚 [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 超级澳洲人 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:16 [post_modified_gmt] => 2019-03-14 20:29:16 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-114/ [menu_order] => 14 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [13] => WP_Post Object ([ID] => 912 [post_author] => 1 [post_date] => 2019-03-14 20:29:07 [post_date_gmt] => 2019-03-14 20:29:07 [post_content] => 番茄、奶酪、火腿、培根、鸡肉、热意大利腊肠和烧烤酱。 [post_title] => MEATLOVERS [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 肉食爱好者 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:17 [post_modified_gmt] => 2019-03-14 20:29:17 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-115/ [menu_order] => 15 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [14] => WP_Post Object ([ID] => 906 [post_author] => 1 [post_date] => 2019-03-14 20:29:06 [post_date_gmt] => 2019-03-14 20:29:06 [post_content] => 番茄、奶酪、火腿、辣椒和热意大利腊肠。 [post_title] => 美洲 [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 关闭 [post_password] => [post_name] => 美国 [to_ping] => [pinged] => [post_modified] => 2019-03-15 00:09:46 [post_modified_gmt] => 2019-03-15 00:09:46 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-109/ [menu_order] => 9 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [15] => WP_Post Object ([ID] => 907 [post_author] => 1 [post_date] => 2019-03-14 20:29:06 [post_date_gmt] => 2019-03-14 20:29:06 [post_content] => 番茄、奶酪、辣椒、辣味腊肠。 [post_title] => MEXICANA [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 墨西哥 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:15 [post_modified_gmt] => 2019-03-14 20:29:15 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-110/ [menu_order] => 10 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [16] => WP_Post Object ([ID] => 908 [post_author] => 1 [post_date] => 2019-03-14 20:29:06 [post_date_gmt] => 2019-03-14 20:29:06 [post_content] => 番茄、奶酪、热意大利腊肠、橄榄和凤尾鱼。 [post_title] => PEPPERONI [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 意大利辣香肠 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:15 [post_modified_gmt] => 2019-03-14 20:29:15 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-111/ [menu_order] => 11 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [17] => WP_Post Object ([ID] => 905 [post_author] => 1 [post_date] => 2019-03-14 20:29:05 [post_date_gmt] => 2019-03-14 20:29:05 [post_content] => 番茄,奶酪 、鸡蛋、火腿、培根和鸡蛋。 [post_title] => 澳大利亚 [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 已关闭 [post_password] => [post_name] => 澳大利亚 [to_ping] => [pinged] => [post_modified] => 2019-03-15 00:13:14 [post_modified_gmt] => 2019-03-15 00:13:14 [post_content_filtered] => [post_parent] => 0 [指导] => http://localhost/harvestpizza/product/import-placeholder-for-108/ [menu_order] => 8 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [18] => WP_Post Object ([ID] => 904 [post_author] => 1 [post_date] => 2019-03-14 20:29:04 [post_date_gmt] => 2019-03-14 20:29:04 [post_content] => 番茄,奶酪 、火腿、蘑菇、橄榄和凤尾鱼。 [post_title] => 卡普里奇奥萨 [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => capriciosa [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:15 [post_modified_gmt] => 2019-03-14 20:29:15 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-107/ [menu_order] => 7 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [19] => WP_Post Object ([ID] => 903 [post_author] => 1 [post_date] => 2019-03-14 20:29:02 [post_date_gmt] => 2019-03-14 20:29:02 [post_content] => 番茄,奶酪 、火腿和蘑菇。 [post_title] => CAPPRI [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 已关闭 [post_password] => [post_name] => cappri [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:15 [post_modified_gmt] => 2019-03-14 20:29:15 [post_content_filtered] => [post_parent] => 0 [指导] => http://localhost/harvestpizza/product/import-placeholder-for-106/ [menu_order] => 6 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [20] => WP_Post Object ([ID] => 901 [post_author] => 1 [post_date] => 2019-03-14 20:29:01 [post_date_gmt] => 2019-03-14 20:29:01 [post_content] => 番茄、奶酪、蘑菇、洋葱、辣椒、橄榄和菠萝。 [post_title] => VEGETERIAN(v) [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 关闭 [post_password] => [post_name] => vegeterianv [to_ping] => [pinged] => [post_modified] => 2019-03-15 00:25:22 [post_modified_gmt] => 2019-03-15 00:25:22 [post_content_filtered] => [post_parent] => 0 [指导] => http://localhost/harvestpizza/product/import-placeholder-for-104/ [menu_order] => 4 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [21] => WP_Post Object ( [ID] => 902 [post_author] => 1 [post_date] => 2019-03-14 20:29:01 [post_date_gmt] => 2019-03-14 20:29:01 [post_content] => 番茄,奶酪 、火腿和菠萝。 [post_title] => 夏威夷语 [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 已关闭 [post_password] => [post_name] => hawaian [to_ping] => [pinged] => [post_modified] => 2019-03-15 00:24:10 [post_modified_gmt] => 2019-03-15 00:24:10 [post_content_filtered] => [post_parent] => 0 [指导] => http://localhost/harvestpizza/product/import-placeholder-for-105/ [menu_order] => 5 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [22] => WP_Post Object ( [ID] => 897 [post_author] => 1 [post_date] => 2019-03-14 20:28:59 [post_date_gmt] => 2019-03-14 20:28:59 [post_content] => 番茄,双倍 奶酪和牛至。 [post_title] => MARGHERITA(V) [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 已关闭 [post_password] => [post_name] => margheritav [to_ping] => [pinged] => [post_modified] => 2019-03-25 12:04:16 [post_modified_gmt] => 2019-03-25 12:04:16 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-100/ [menu_order] => 0 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) [23] => WP_Post Object ( [ID] => 898 [post_author] => 1 [post_date] => 2019-03-14 20:28:59 [post_date_gmt] => 2019-03-14 20:28:59 [post_content] => Garlic,double 奶酪、牛至和盐。 [post_title] => GARLIC(v) [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 关闭 [post_password] => [post_name] => garlicv [to_ping] => [pinged] => [post_modified] => 2019-03-25 14:55:56 [post_modified_gmt] => 2019-03-25 14:55:56 [post_content_filtered] => [post_parent] => 0 [指导] => http://localhost/harvestpizza/product/import-placeholder-for-101/ [menu_order] => 1 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [24] => WP_Post Object ([ID] => 899 [post_author] => 1 [post_date] => 2019-03-14 20:28:59 [post_date_gmt] => 2019-03-14 20:28:59 [post_content] => 大蒜,奶酪 和草药。 [post_title] => FOCACCIA(V) [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => focacciav [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:14 [post_modified_gmt] => 2019-03-14 20:29:14 [post_content_filtered] => [post_parent] => 0 [指导] => http://localhost/harvestpizza/product/import-placeholder-for-102/ [menu_order] => 2 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw) [25] => WP_Post Object ([ID] => 900 [post_author] => 1 [post_date] => 2019-03-14 20:28:59 [post_date_gmt] => 2019-03-14 20:28:59 [post_content] => 番茄,加载 蘑菇配奶酪。 [post_title] => 蘑菇(V) [post_excerpt] => [post_status] => 发布 [comment_status] => 关闭 [ping_status] => 关闭 [post_password] => [post_name] => 蘑菇 [to_ping] => [pinged] => [post_modified] => 2019-03-15 00:26:09 [post_modified_gmt] => 2019-03-15 00:26:09 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/harvestpizza/product/import-placeholder-for-103/ [menu_order] => 3 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [filter] => raw ) ) [post_count] => 26 [current_post] => -1 [in_the_loop] => [post] => WP_Post 对象([ID] => 922 [post_author] => 1 [post_date] => 2019-03-14 20:29:12 [post_date_gmt] => 2019-03-14 20:29:12 [post_content] => [post_title] => 巧克力披萨 [post_excerpt] => [post_status] => 发布 [comment_status] => 打开 [ping_status] => 关闭 [post_password] => [post_name] => 巧克力披萨 [to_ping] => [pinged] => [post_modified] => 2019-03-14 20:29:18 [post_modified_gmt] => 2019-03-14 20:29:18 [post_content_filtered] => [post_parent] => 0 [指导] => http://localhost/harvestpizza/product/import-placeholder-for-125/ [menu_order] => 25 [post_type] => 产品 [post_mime_type] => [comment_count] => 0 [过滤器] => raw ) [comment_count] => 0 [current_comment] => -1 [found_posts] => 26 [max_num_pages] => 1 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => 1 [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax ] => 1 [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => [is_404] => [is_embed] => [is_paged] => [is_admin] => [ is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => [is_post_type_archive] => 1 [query_vars_hash:WP_Query:private] => 5efdffdb75153bccce8880eb2980f959 [query_vars_changed:WP_Query:private] => 1 [thumbnails_cached] => [stopwords:WP_Query:private] => [compat_fields:WP_Query:private] => 数组 ([0] => query_vars_hash [1] => query_vars_changed ) [compat_methods:WP_Query:private] => 数组 ( [0] => init_query_flags [1] => parse_tax_query ) )
【问题讨论】:
【参考方案1】:$args = array(
'post_type'=>'product',
'posts_per_page' => 10,
'no_found_rows' => true,
'update_post_term_cache' => false,
'update_post_meta_cache' => false,
'nopaging' => true,
'order' => 'DESC',
);
$query = new WP_Query( $args );
根据您的需要修改它。我希望它能正常工作:)
【讨论】:
以上是关于WP_Query($args) 在 Wordpress 中不起作用的主要内容,如果未能解决你的问题,请参考以下文章