logo

Box catégories

Code


    <div class="container is-fluid"> 
 
<?php 
$last = get_categories(); 
foreach($last as $cat){ 
?> 
 
<section class="section"> 
  <div class="container"> 
    <div class="columns is-vcentered"> 
      <div class="column is-6 mb-5"> 
        <h2 class="title"><?php echo $cat->name;//the_category() ?></h2> 
        <div class="title is-5"><?php echo $cat->category_description;//category_description();?></div> 
        <div class="buttons is-pulled-right pr-5"><a class="button is-primary" href="<?php echo site_url().'/?cat='. $cat->term_id;?>">Voir !</a></div> 
      </div> 
      <div class="column is-6"> 
 
        <?php 
        $args = array( 
          'category' => $cat->term_id, 
        ); 
        $posts = get_posts($args); 
        $nombre_posts = count($posts); 
        $i = 3; 
        $j = 1; 
        while($i > 0){ 
          $post = $posts[$nombre_posts - $i]; 
          $lien = $post->guid; 
        ?> 
 
        <div class="media"> 
          <div class="media-left"> 
            <div class="number has-background-primary"><?php echo $j++; ?> 
          </div> 
          </div> 
          <div class="media-content"> 
            <div class="content"> 
              <h3><?php echo $post->post_title;//the_title(); ?></h3> 
              <p><?php echo $post->post_excerpt;//the_excerpt()?></p> 
            </div> 
          </div> 
        </div> 
        <?php  
        $i = $i -1 ; 
      }//endwhile; ?> 
      </div> 
    </div> 
  </div> 
</section> 
<?php //endwhile; 
  } ?> 
</div>

 

Code


     
<div class="container is-fluid"> 
 
<?php 
$last = get_categories(); 
foreach($last as $cat){ 
?> 
 
<section class="section"> 
  <div class="container"> 
    <div class="columns is-vcentered"> 
      <div class="column is-6 mb-5"> 
 
          <?php  
            $image_id = get_term_meta ( $cat->term_id, 'category-image-id', true ); 
            $image = wp_get_attachment_image ( $image_id, 'thumbnail' ); 
            echo $image; 
          ?> 
 
        <h2 class="title"><?php echo $cat->name;//the_category() ?></h2> 
        <div class="title is-5"><?php echo $cat->category_description;//category_description();?></div> 
        <div class="buttons is-pulled-right pr-5"><a class="button is-primary" href="<?php echo site_url().'/?cat='. $cat->term_id;?>">Voir !</a></div> 
      </div> 
      <div class="column is-6"> 
 
        <?php 
        $args = array( 
          'category' => $cat->term_id, 
        ); 
        $posts = get_posts($args); 
        $nombre_posts = count($posts); 
        $i = 3; 
        $j = 1; 
        while($i > 0){ 
          $post = $posts[$nombre_posts - $i]; 
          $lien = $post->guid; 
        ?> 
 
        <div class="media"> 
          <div class="media-left"> 
            <div class="number has-background-primary"><?php echo $j++; ?> 
          </div> 
          </div> 
          <div class="media-content"> 
            <div class="content"> 
              <h3><?php echo $post->post_title;//the_title(); ?></h3> 
              <p><?php echo $post->post_excerpt;//the_excerpt()?></p> 
            </div> 
          </div> 
        </div> 
        <?php  
        $i = $i -1 ; 
      }//endwhile; ?> 
      </div> 
    </div> 
  </div> 
</section> 
<?php //endwhile; 
  } ?> 
</div>