0

I use this in a page template, I am hoping for a solution to filling in the 'XXXXX' space with the current term selected of the taxonomy 'place'. I don't think i can do_shortcode within an array. I am not very good at php or wordpress. Thanks in advance.

$pages = get_posts(array(
  'post_type' => 'directory_listing',
  'posts_per_page' => -1,
  'tax_query' => array(
    array(
      'taxonomy' => 'place',
      'field' => 'id',
      //'terms' => 'the-damn-bar',
      'terms' => 'XXXXX',
      'include_children' => false
    )
  ))
);



foreach ($pages as $mypost) {
      echo '<div class="specialList">';
      echo $mypost->post_content . '<br/>';
      echo '</div>';
}
?>
Joe Barrett
  • 135
  • 1
  • 1
  • 10

1 Answers1

0

The WordPress function to use here is get_terms(), although this will return all terms associated with this taxonomy;

$terms = get_terms(
    'place'
);

Codex: http://codex.wordpress.org/Function_Reference/get_terms

There are some related functions which might make life easier too.

Also, some including myself prefer to use WP_Query() rather than get_posts(). It's much better to use of you have post loops nested in others.

mrbubbles
  • 687
  • 6
  • 19