On clicking on the category name the page is redirecting on 404 pge

I have created a custom post type and added 60 posts and added each post in the category. I am able to display the post and category on the page and I am using the below code

function intelligenceList( $  atts ){   $  args = array(           'post_type' => 'intelligence',         'post_status' => 'publish',         'posts_per_page' => 70,          //'orderby' => 'title',          //'order' => 'ASC',      );    if(!empty($  _REQUEST['keyword'])){ $  args = array(   'post_type' => 'intelligence',   's' => $  _REQUEST['keyword'],   // 'meta_query' => array(   //   array(   //     'key' => $  _REQUEST['keyword'],   //     'value' => $  _REQUEST['keyword'],   //     'compare' => 'LIKE'   //   ),         // ) ); }   $  loop = new WP_Query($  args);     $  data ='';    $  data.='<div class="intelligenceList innerBox"><ul>';    if($  loop->have_posts() ) {         while($  loop->have_posts() ) {         $  loop->the_post();         $  tid = $  loop->ID;     $  calegoryList = get_the_terms( $  tid , 'intelligence_cats' );     foreach ( $  calegoryList as $  cat ) {       $  category_link = esc_attr( esc_url( get_category_link( $  cat->term_id ) ) );       $  catname=$  cat->name;         }              $  data .='<li>                 <div class="intelligenceBanner"> <img src="'.get_the_post_thumbnail_url($  tid,'large').'" alt="'.get_the_title($  tid).'" class="thumbnailPic">                 </div>                 <div class="intelligenceContent">                 <h6><a href="'.$  category_link.'">'.$  catname.'</a></h6>               <h3>'.wp_trim_words(get_the_title($  tid),9, '...').'</h3>               <p>'.wp_trim_words(get_the_excerpt($  tid),40, '...').'</p>               <a href="'.get_permalink().'">READ</a>               </div>             </li>';             }         }         else{           $  data.='<li>Sorry, no posts matched your criteria.</li>';         }  $  data .='</ul></div>'; echo $  data;   //return $  postData;  wp_die(); // it will remove 0. } 

Is there any issue with the below code? because when I click on a category then it’s redirecting to the 404 pages. I am using below code for categroy

foreach ($  calegoryList as $  cat) {           $  category_link = esc_attr( esc_url( get_category_link( $  cat->term_id ) ) );           $  catname=$  cat->name;          }       <h6><a href="'.$  category_link.'">'.$  catname.'</a></h6> 

I try to reset the permalink setting but still going to the 404 pages. Would you help me out how to hyperlink the category name?

Do I need to create the category.php page