How to get post name from taxonomy

I have created custom post namely solution. I created taxonomy using register_taxonomy namely solution_category. I created two category are

  1. By Function
  2. By Industry

How to get By Function Post?

Related posts

2 comments

  1. Try this:

    $cargs = array(
        'post_type' => 'my_post_type',
        'posts_per_page'=>-1,
        'tax_query' => array(
                'taxonomy' => 'my_taxonomy',
                'field' => 'slug',
                'terms' => 'webdesign'
            )       
    );
    $cwp_query = new WP_Query($cargs);
    while ($cwp_query->have_posts()) : $cwp_query->the_post(); 
    print_r($post);
    endwhile;
    
  2. CODE:

    $terms = get_terms('solution_category');
    // Initially get all categories
    
    foreach ($terms as $term) 
    {
       $wpq = array ('taxonomy'=>'solution_category','term'=>$term->slug);
       $query = new WP_Query ($wpq);
       $article_count = $query->post_count;
    
       echo "<h3 Style='border-bottom: 1px solid #ccc;' class="term-heading" id="".$term->slug."">";
       echo $term->name;
       echo "</h3>";
    
       if ($article_count) {
          echo "<ul>";
          $posts = $query->posts;
          foreach ($posts as $post) {
          echo "<li><a href="".get_permalink()."">".$post->post_title."     </a></li>";
       }
       echo "</ul>";
    }
    

    output:

    enter image description here

Comments are closed.