The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress: Display Custom Posts by Custom Category

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #167129

    I’m really confused right now. I’ve been trying to display my custom posts but cannot make it to be grouped by their custom category(taxonomy). I have managed to display them by category but the category is hard-coded. These is what I got at the moment.

    $args = array(
      'post_type' => 'foods',
      'tax_query' => array(
          'taxonomy' => 'food_categories',
          'field' => 'slug',
          'terms' => 'bread'
    $foods = new WP_Query($args);
    if($foods->have_posts()) {
      while($foods->have_posts()) {
        <h1><?php the_title(); ?></h1>
          &lt;?php the_content(); ?&gt;
    else {
      echo 'no foods';


    How can I display all my custom post grouped by their respective “Category” by not hard coding the “category name”?

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.