Advertisement
Guest User

archive.php

a guest
Jul 13th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.96 KB | None | 0 0
  1. <?php
  2. // Ver https://br.wordpress.org/support/topic/problemas-com-categorias/
  3. /**
  4.  * The template for displaying archive pages
  5.  *
  6.  * @link https://codex.wordpress.org/Template_Hierarchy
  7.  *
  8.  * @package piradigital
  9.  */
  10.  
  11. get_header(); ?>
  12.     <div id="primary" class="content-area">
  13.         <main id="main" class="site-main">
  14.         <div class="container">
  15.             <div class="row">
  16. <?php
  17.         if ( have_posts() ) : ?>
  18.  
  19.             <header class="page-header">
  20. <?php
  21. $args = array(
  22.     'category_name' => $slug
  23. );
  24. $terms = get_the_terms( get_the_ID(), 'category');
  25. if( !empty($terms) ) :
  26.     $term = array_pop($terms);
  27.     $cor = get_field('cor', $term );
  28.     $slug = $term->slug;
  29. endif;
  30. ?>
  31.  
  32. <h1 style="color:<?php echo $cor; ?>" class="page-title tac"><?php echo $term->name; ?></h1>
  33.              
  34.  
  35.                
  36.             </header><!-- .page-header -->
  37.            
  38. <!-- Notícia em destaque -->          
  39. <!-- Notícia sozinha na DIV -->
  40.             <?php
  41.  
  42.                                     $terms = get_the_terms( get_the_ID(), 'category');
  43.                                     if( !empty($terms) ) :
  44.                                         $term_ids = wp_list_pluck( $terms, 'term_id' );
  45.                                     endif;
  46.  
  47.                             // The Query
  48.                             $args = array(
  49.                                 'post_type' => 'post',
  50.                                 'posts_per_page' => 2,
  51.                                 'category__in' => $term_ids
  52.                             );
  53.                             $query = new WP_Query( $args );
  54.                             if ( $query->have_posts() ) :
  55.                                 $cols = 0;
  56.                                 $ids = array();
  57.                                 while ( $query->have_posts() ) : $query->the_post();
  58.                                 $ids[] = get_the_ID();
  59.                                 $terms = get_the_terms( get_the_ID(), 'category');
  60.                                     if( !empty($terms) ) :
  61.                                         $term = array_pop($terms);
  62.                                         $cor = get_field('cor', $term );
  63.                                     endif;
  64.  
  65.                                     ?>
  66. <div class="col-md-6">
  67.     <a href="<?php echo get_permalink(); ?>">
  68.         <h1 class="title-main" style="color:<?php echo $cor; ?>">
  69.             <?php echo get_field('titulo_chamada'); ?>
  70.         </h1>
  71.     </a>
  72.    
  73.     <a href="<?php echo get_permalink(); ?>">
  74.         <div class="img-destaque img-responsive" style="background-image: url(<?php the_post_thumbnail_url(); ?>); ">
  75.             <div class="tag-category branco" style="background-color: <?php echo $cor; ?>">
  76.                 <?php echo $term->name; ?>
  77.             </div> 
  78.         </div>
  79.     </a>
  80.      <?php the_excerpt(); ?>
  81.  
  82. </div>
  83.                                     <?php
  84.  
  85.                                 endwhile;
  86.                                 /* Restore original Post Data */
  87.                                 wp_reset_postdata();
  88.                 endif;
  89.             ?>
  90.                         <!-- PUBLICIDADE -->
  91.                         <div class="col-md-6 col-xs-12 img-responsive mw100pc" style="float: right;">
  92.                             <?php echo do_shortcode("[pro_ad_display_adzone id=7562]"); ?>
  93.                         </div>
  94.  
  95.                         <div class="col-md-6 col-xs-12 img-responsive mw100pc" style="float: right;">
  96.                             <?php echo do_shortcode("[pro_ad_display_adzone id=1043]"); ?>
  97.                         </div>
  98.  
  99. <!-- Quatro primeiras notícias -->
  100. <div class="col-md-12">
  101.      <div class="row">
  102.         <?php
  103.  
  104.             $terms = get_the_terms( get_the_ID(), 'category');
  105.                             if( !empty($terms) ) :
  106.                                 $term_ids = wp_list_pluck( $terms, 'term_id' );
  107.                             endif;
  108.                             // The Query
  109.                             $args = array(
  110.                                 'post_type' => 'post',
  111.                                 'post__not_in' => $ids,
  112.                                 'posts_per_page' => 4,
  113.                                 'category__in' => $term_ids,
  114.                                 ‘showposts’ => 1,
  115.                                 ‘paged’=>$paged
  116.                             );
  117.                             $query = new WP_Query( $args );
  118.                             if ( $query->have_posts() ) :
  119.                                 $cols = 0;
  120.                                 while ( $query->have_posts() ) : $query->the_post();
  121.                                 $ids[] = get_the_ID();
  122.                                 $terms = get_the_terms( get_the_ID(), 'category');
  123.                                     if( !empty($terms) ) :
  124.                                         $term = array_pop($terms);
  125.                                         $cor = get_field('cor', $term );
  126.                                     endif;
  127.  
  128.                                     ?>
  129.             <div class="col-md-3" style="height: 620px;">
  130.                 <a href="<?php echo get_permalink(); ?>">
  131.                     <h1 class="title-main" style="color:<?php echo $cor; ?>">
  132.                         <?php echo get_field('titulo_chamada'); ?>
  133.                     </h1>
  134.                 </a>
  135.                                        
  136.                 <a href="<?php echo get_permalink(); ?>">
  137.                     <div class="img-destaque" style="background-image: url(<?php the_post_thumbnail_url(); ?>); ">
  138.                         <div class="tag-category branco" style="background-color: <?php echo $cor; ?>">
  139.                             <?php echo $term->name; ?>
  140.                         </div> 
  141.                     </div>
  142.                 </a>
  143.                 <?php the_excerpt(); ?>            
  144.  
  145.             </div>
  146.             <?php                  
  147.                 endwhile;      
  148.                     /* Restore original Post Data */
  149.                     wp_reset_postdata();
  150.                 endif;
  151.             ?>
  152.      </div>
  153. </div>
  154.  
  155. <!-- Resto das noticias da categoria -->
  156.         <div class="col-md-12">
  157.             <div class="slide-noticias">
  158.             <?php
  159.  
  160.             $terms = get_the_terms( get_the_ID(), 'category');
  161.                                     if( !empty($terms) ) :
  162.                                         $term = array_pop($terms);
  163.                                         $slug = $term->slug;
  164.                                     endif;
  165.                             // The Query
  166.                             $args = array(
  167.                                 'post_type' => 'post',
  168.                                 'post__not_in' => $ids,
  169.                                 'posts_per_page' => 4,
  170.                                 'category_name' => $slug,
  171.                                 ‘showposts’ => 1,
  172.                                 ‘paged’=>$paged
  173.                             );
  174.                             $query = new WP_Query( $args );
  175.                             if ( $query->have_posts() ) :
  176.                                 $cols = 0;
  177.                                 while ( $query->have_posts() ) : $query->the_post();
  178.                                 $ids[] = get_the_ID();
  179.                                 $terms = get_the_terms( get_the_ID(), 'category');
  180.                                     if( !empty($terms) ) :
  181.                                         $term = array_pop($terms);
  182.                                         $cor = get_field('cor', $term );
  183.                                     endif;
  184.  
  185.                                     ?>
  186.                                     <div class="col-md-3" style="height: 620px;"><a href="<?php echo get_permalink(); ?>">
  187.                                     <h1 class="title-main" style="color:<?php echo $cor; ?>"><?php echo get_field('titulo_chamada'); ?></h1></a>
  188.                                         <a href="<?php echo get_permalink(); ?>">
  189.                                         <div class="img-destaque" style="background-image: url(<?php the_post_thumbnail_url(); ?>); ">
  190.  
  191.                                         <div class="tag-category branco" style="background-color: <?php echo $cor; ?>"><?php echo $term->name; ?></div>
  192.                                         </div>
  193.                                         </a>
  194.                                         <?php the_excerpt(); ?>            
  195.  
  196.                                     </div>
  197.                                     <?php
  198.                                    
  199.                                 endwhile;
  200.        
  201.                                
  202.                                 /* Restore original Post Data */
  203.                                 wp_reset_postdata();
  204.                 endif;
  205.             ?>
  206.             </div>
  207.         </div>
  208.            
  209.             <!-- Paginação -->
  210.  
  211.             <div class="clear"></div>
  212.  
  213.             <br />
  214.             <br />         
  215.  
  216.             <!--BANNER-->
  217.                  <div class="col-xs-12 img-responsive" id="closer">
  218.                     <?php echo do_shortcode("[pro_ad_display_adzone id='1049' class='banner-categoria']"); ?>
  219.              <a hrfe="#" class="modal-close hidden-xs" onclick="document.getElementById('closer').style.display='none'"></a>
  220.                 </div>  <!-- /.publicidade -->
  221.                        
  222.                         <div class="clear"></div>
  223.  
  224. <!-- PROVISÓRIO -->
  225.  
  226. <hr>
  227.  
  228.                         <?php
  229.                                 // The Query
  230.                                 $args = array(
  231.                                     'post_type' => 'post',
  232.                                     'category_name' => $term->slug,
  233.                                     'post__not_in' => $ids,
  234.                                     'posts_per_page' => 10
  235.                                 );
  236.                                 $query = new WP_Query( $args );
  237.                                 if ( $query->have_posts() ) :
  238.  
  239.                                     $colun = 1;
  240.                                         while ( $query->have_posts() ) : $query->the_post();
  241.                                         $terms = get_the_terms( get_the_ID(), 'category');
  242.                                         if( !empty($terms) ) :
  243.                                             $term = array_pop($terms);
  244.                                             $cor = get_field('cor', $term );
  245.                                         endif;
  246.                                         ?>
  247.                                             <?php if($colun == 1 or $colun == 6) : ?><div class="col-md-6"><?php endif; ?>
  248.                                             <a href="<?php echo get_permalink(); ?>" style="color:<?php echo $cor; ?>"><h1 class="title-resume"><?php echo get_field('titulo_chamada'); ?></h1></a>
  249.                                             <?php echo get_the_date(); ?>
  250.                                             <hr>
  251.                                             <?php if($colun == 5 or $colun == 10) : ?></div><?php endif; ?>
  252.                                         <?php
  253.  
  254.                                         $colun++;
  255.  
  256.                                     endwhile;
  257.                                     /* Restore original Post Data */
  258.                                     wp_reset_postdata();
  259.                                 endif;
  260.                             ?>
  261. <?php endif; ?> <!-- DEVE PERMANECER NA PÁGINA -->
  262.  
  263.         </main><!-- #main -->
  264.     </div><!-- #primary -->
  265.    
  266.     <br />
  267.     <br />
  268.     <br />
  269.  
  270. <?php
  271. get_footer();
  272. ?>
  273. <script type="text/javascript" async src="https://d335luupugsy2.cloudfront.net/js/loader-scripts/7270b716-ffb6-4f76-8de0-9f09b12a4159-loader.js"></script>
  274.  
  275. <script>
  276.   (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  277.   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  278.   m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  279.   })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  280.  
  281.   ga('create', 'UA-68151385-5', 'auto');
  282.   ga('send', 'pageview');
  283.  
  284. </script>
  285.  
  286. <script>
  287. $('.slide-noticias').slick({
  288.   infinite: true,
  289.   slidesToShow: 4,
  290.   slidesToScroll: 4,
  291.   dots: true,
  292.   infinite: false,
  293.   speed: 300,
  294.   slidesToShow: 4,
  295.   slidesToScroll: 4,
  296.   responsive: [
  297.     {
  298.       breakpoint: 1024,
  299.       settings: {
  300.         slidesToShow: 3,
  301.         slidesToScroll: 3,
  302.         infinite: true,
  303.         dots: true
  304.       }
  305.     },
  306.     {
  307.       breakpoint: 600,
  308.       settings: {
  309.         slidesToShow: 2,
  310.         slidesToScroll: 2
  311.       }
  312.     },
  313.     {
  314.       breakpoint: 480,
  315.       settings: {
  316.         slidesToShow: 1,
  317.         slidesToScroll: 1
  318.       }
  319.     }
  320.     // You can unslick at a given breakpoint now by adding:
  321.     // settings: "unslick"
  322.     // instead of a settings object
  323.   ]
  324. });
  325. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement