30 March 2021

Wordpress Post Display According Category Id

 <section class="product-category">

  <div class="container">

    <div class="product-category-inner">


      <ul>

  <?php 

  $ids = array( 32, 35, 36, 48, 42, 64 );

  $i = "delay-1";

    $args = array(

      'orderby' => 'id',

      'hierarchical' => 1,

      'taxonomy' => 'product_cat',

      'hide_empty' => 0,

      'parent' => 0,

  'exclude' =>1,

    );

    $categories = get_categories($args);


    foreach($categories as $category) {

        if(in_array($category->cat_ID,$ids) and $temp_i<6){

            $temp_i++;

?>

        <li  class="block animatable bounceInLeft <?php echo $i++ ?> ">

          <div class="product-category-content">

            <h3><a href="<?php echo get_category_link($category->cat_ID); ?>"><?php echo $category->name; ?></a></h3>

            <p><?php echo substr(strip_tags($category->description),0,100 )?>...</p>

          </div>

        </li>

<?php }

    }

?>

      </ul>

    </div>

  </div>

</section>