Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.04 KB | None | 0 0
  1. <?php
  2. get_header();
  3. $categoryPosts = get_posts( array(
  4.     'posts_per_page'   => -1,
  5.     'category'         => get_query_var( 'cat' ),
  6. ));
  7. $categoryPostsImages = array();
  8.  
  9. $categories = get_categories( array(
  10.     'orderby' => 'name',
  11.     'order'   => 'ASC',
  12.     'parent' => 52,
  13.     'hide_empty' => 0
  14. ));
  15.  
  16. if ( $categoryPosts ) {
  17.     foreach ( $categoryPosts as $post ){
  18.         $postImages = get_attached_media( 'image', $post->ID );
  19.         if ( $postImages ) {
  20.             $postImages = array_slice( $postImages, 0, 5 );
  21.             $categoryPostsImages ? $categoryPostsImages =  array_merge( $categoryPostsImages, $postImages ): $categoryPostsImages = $postImages;
  22.         }
  23.     }
  24. }
  25. ?>
  26.  
  27.     <div class="container">
  28.          <?php echo category_description( get_query_var( 'cat' ) ); ?>
  29.     </div>
  30.  
  31.     <div class="rowproduse">
  32.         <div class="col-md-3">
  33.             <?php if( $categories ): ?>
  34.             <ul class="main-categ">
  35.                 <?php foreach ( $categories as $kCat => $vCat ): ?>
  36.  
  37.                 <li id="main-item-class" class="main-item <?php echo get_category( $vSub->cat_ID ) == $vCat->slug ? 'active' : ''; ?>"><?php
  38.                     $subCategories = get_categories( array(
  39.                         'orderby' => 'name',
  40.                         'order'   => 'ASC',
  41.                         'parent' => $vCat->cat_ID,
  42.                         'hide_empty' => 0
  43.                     ));?>
  44.                     <a class="main-link" href="#<?php echo $vCat->slug; ?>" data-cat="<?php echo $vCat->slug; ?>"><?php echo $vCat->name; ?></a>
  45.                     <?php if( $subCategories ): ?>
  46.                     <ul class="subcateg">
  47.                         <?php foreach ( $subCategories as $kSub => $vSub ): ?>
  48.                         <li><a href="<?php echo esc_url( get_category_link( $vSub->cat_ID ) ); ?>"><i class="fa fa-angle-double-right"></i> <?php echo $vSub->name; ?></a></li>
  49.                         <?php endforeach; ?>
  50.                     </ul>
  51.                     <?php endif; ?>
  52.                 </li>
  53.                 <?php endforeach; ?>
  54.             </ul>
  55.             <?php endif; ?>
  56.         </div>
  57.         <div class="col-md-9">
  58.             <?php if ( $categoryPosts ): ?>
  59.                 <div class="row">
  60.                     <?php $i = 1; while(have_posts()) : the_post();?>
  61.                         <div class="col-md-6 rand-produse">
  62.                             <div class="preview-panel">
  63.  
  64.                                 <div class="row">
  65.                                     <div class="col-md-6 image"><a href="<?php if( $post->ID == 80 ) echo get_site_url() . "/comanda-online/?p=" . $post->post_title; else the_permalink(); ?>"><img src="<?php the_post_thumbnail_url( 'full' ); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>"></a></div>
  66.                                     <div class="col-md-6">
  67.                                             <h4><?php the_title(); ?></h4>
  68.                                             <div class="text-produs-paragraf"><?php $excerpt= get_the_excerpt();echo substr($excerpt, 0, 170),'...'; ?></div>
  69.                                             <a href="<?php if( $post->ID == 80 ) echo get_site_url() . "/comanda-online/?p=" . $post->post_title; else the_permalink(); ?>" class="btn btn-primary" role="button"><?php echo $post->ID == 80 ? 'Comandă Online':'Vezi Detalii'; ?> <span><i class="fa fa-angle-double-right"></i></span></a>
  70.                                     </div>
  71.                                 </div>
  72.                             </div>
  73.                     </div>
  74.                     <?php if ( $i % 2 === 0 ) { echo '</div><div class="row">'; } ?>
  75.                     <?php $i++; endwhile; wp_reset_query(); ?>
  76.                 </div>
  77.             <?php endif; ?>
  78.         </div>
  79.  
  80.     </div>
  81. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement