enter image description here

Following is my categories page. It’s listing the all categories in the page.
But when gets blank value here. see the attached screen shot.
Why href is blank here

 li><a href="<?php echo esc_url(   $category_link ); ?>"><?php echo $cat- >name; ?></a></li>

Here the the complete code

<? php
    /*
    Template Name: Categories
    */
        get_header(); 
        $cats =  get_categories();
        $num_cats  = wp_count_terms('category'); 
        $count = $num_cats;  // Total Categories
        $linetotal=round($count/3); // Part of Category
        $cat1 = get_query_var('cat');
        $category_link = get_category_link( $cat1 );    
        ?>
        <!-- Main body section begins -->   
    <div class="row">   
      <div class="medium-4 large-4 columns category_list">
        <ul>
            <?php
          $totalcount = 1;
          $totalpart = 1;
          foreach($cats as $cat): ?>
            <li><a href="<?php echo esc_url( $category_link ); ?>"><?php echo $cat->name; ?></a></li>
            <?php
            if($totalcount % $linetotal == 0 && $totalpart < 3) { 
              echo '</ul></div><div class="medium-4 large-4 columns category_list"><ul>';
                  $totalpart++;
            }
            $totalcount++;
          endforeach;?>
        </ul>
      </div>
     </div>
    <?PHP get_footer(); ?>

Any suggestions will be appreciated.

Read more here: Anchor tag generates blank href attribute using echo esc_url( )


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , , ,

Wordpress related questions and answers: