Advanced taxonomy queries
-
Hello. I have been scratching my head for a little while on this one.
I have a custom post called “Slider” and a taxonomy called “Slider Categories”. Depending on the page I would like to display a slider based on the Slider Category.
Here is my code:
/THE FUNCTION THAT WILL OUTPUT THE SLIDER
function slideshow($slider_category) {
/* Query from the database. */
$loop = new WP_Query(
array(
‘post_type’ =>’slider’,
‘posts_per_page’ => -1,
‘orderby’ =>’ID’,
‘order’ =>’ASC’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘slider_category’,
‘terms’ => array( $slider_category ),
‘field’ => ‘id’
) )
)
);And on my page template I have
$slider_category=’7′;
echo slideshow();Any suggestions on how to get it to work correctly?
- The topic ‘Advanced taxonomy queries’ is closed to new replies.