2012-07-12 59 views
1

由于我已经建立了我的模板的方式,我需要有一个字符串的URL格式如下:如何将我的数组查询转换为wordpress中的字符串查询?

$the_query = array('post_type' => 'product', 'taxonomy' => 'product_types', 'term' => 'solar-panel') 

我觉得像

$the_query = new WP_Query('post_type=product&taxonomy=product_types&term=solar-panel&showposts=2') 

但这不是由于工作到分类学本身就是一个数组这一事实。谢谢。

+0

它确定它实际上是工作,我的错误 – Nicola 2012-07-12 15:45:43

回答

0

您的模板是否允许您在WP_Query之外设置选项?

$args=array(
    'post_type' => 'product', 
    'taxonomy' => 'product_types', 
    'term' => 'solar-panel', 
); 

$the_query = new WP_Query($args); 

如果不是,那么你的模板怎么样不会让你这样做?你可以发布一些代码吗?

+0

没关系,我设法以字符串格式。我想我是在想,如果我按照你发布的方式来完成,那么我将不得不做一个foreach循环,但我不这样做?它仍然可以是<?php while($ the_query - > have_posts()):$ the_query - > the_post(); ?> – Nicola 2012-07-13 08:33:13

相关问题