web/wp-content/themes/selecta/archives.php
changeset 1 0d28b7c10758
equal deleted inserted replaced
0:0d9a58d2c515 1:0d28b7c10758
       
     1 <?php
       
     2 	/* Template Name: Selecta Archives */
       
     3 	global $wpdb, $is_archive;
       
     4 	$is_archive = "1";
       
     5 	if(file_exists("../../../wp-blog-header.php")) :
       
     6 		require_once("../../../wp-blog-header.php");
       
     7 	endif;
       
     8 	if($_GET["month"]) :
       
     9 		$use_date = StrToDate("15/".$_GET["month"]."/".$_GET["year"]);
       
    10 		echo $use_date;
       
    11 	endif;
       
    12 	//DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts  
       
    13 	$fetch_archive = $wpdb->get_results("SELECT * FROM " . $wpdb->posts . " WHERE post_status='publish' AND post_type = 'post' GROUP BY $wpdb->posts.ID ORDER BY post_date DESC");
       
    14 	$last_month = date("m Y", strtotime($fetch_archive[0]->post_date));
       
    15 	get_header(); 
       
    16 ?>
       
    17 <div id="content-container">
       
    18     <div id="archive-detail-1">
       
    19 		<h2 class="post-section-title"><?php echo date("M Y", strtotime($fetch_archive[0]->post_date)); ?></h2>
       
    20         <div class="post-slider clearfix">
       
    21             <ul>
       
    22                 <?php
       
    23                     $count = 0;
       
    24                     $month_count = 1;
       
    25                     $last_month = date("m Y", strtotime($fetch_archive[0]->post_date));
       
    26                     foreach($fetch_archive as $archive_data) :                    	
       
    27                         $get_post_video = get_post_meta($post->ID, "main_video", true);
       
    28                         $get_thumbnail = get_post_meta($archive_data->ID, "other_media", true);
       
    29                         $get_video_thumbnail = get_post_meta($archive_data->ID, "video_thumbnail", true);
       
    30                         $post_image = "";
       
    31                         if($get_thumbnail == "") :
       
    32                             $post_image =  fetch_post_image($archive_data->ID, "300", "2000");
       
    33                         endif;
       
    34                         $category_id = get_the_category($archive_data->ID);
       
    35                         $this_category = get_category($category_id[0]->term_id);
       
    36                         $this_category_link = get_category_link($category_id[0]->term_id);
       
    37                         $link = get_permalink($archive_data->ID);
       
    38                         if(date("m Y", strtotime($archive_data->post_date)) !== $last_month) :
       
    39                             $count = 1;
       
    40 							$month_count++;
       
    41                         ?>
       
    42                                     </ul>
       
    43                                 </div>
       
    44                             </div>
       
    45                             <div id="archive-detail-<?php echo $month_count; ?>" style="display: none;">
       
    46                             	<h2 class="post-section-title"><?php echo date("M Y", strtotime($archive_data->post_date)); ?></h2>
       
    47                                 <div class="post-slider clearfix">
       
    48                                     <ul>
       
    49                         <?php elseif($count == 4) :
       
    50                             $count = 1;
       
    51                         ?>
       
    52                                 </ul>
       
    53                             </div>
       
    54                             <div class="post-slider clearfix">
       
    55                                 <ul>
       
    56                         <?php
       
    57                         else :	
       
    58                             $count++;
       
    59                         endif;
       
    60                         ?>
       
    61                         <li class="clearfix"<?php if($count == 4) : echo " class=\"last\""; endif; ?>>
       
    62                             <div class="container-header-light-normal"><span></span></div>
       
    63 							<div class="container-light">
       
    64 								<div class="thumbnail">
       
    65 									<?php if ($get_video_thumbnail !== "") : ?>
       
    66 										<img src="<?php bloginfo('template_directory'); ?>/functions/timthumb.php?src=<?php echo $get_video_thumbnail ?>&amp;h=&amp;w=300&amp;zc=1" alt="<?php echo $archive_data->post_title; ?>" />
       
    67 									<?php elseif($get_thumbnail !== "") : ?>
       
    68 										<img src="<?php echo bloginfo('template_directory'); ?>/functions/timthumb.php?src=<?php echo $get_thumbnail ?>&amp;w=300&amp;h=&amp;zc=1" alt="<?php echo $archive_data->post_title; ?>" />
       
    69 									<?php  elseif ($post_image !== "") :
       
    70 										echo $post_image; 
       
    71 									elseif($get_post_video !== "") :
       
    72 										$get_post_video = preg_replace("/(width\s*=\s*[\"\'])[0-9]+([\"\'])/i", "$1 190 $2", $get_post_video);
       
    73 										$get_post_video = preg_replace("/(height\s*=\s*[\"\'])[0-9]+([\"\'])/i", "$1 137 $2", $get_post_video);
       
    74 											echo $get_post_video;
       
    75 									else : ?>
       
    76 										<img src="<?php bloginfo('template_directory'); ?>/images/slider-test-vid.png" alt="<?php echo $archive_data->post_title; ?>" />
       
    77 									<?php endif; ?>
       
    78 								</div>
       
    79 							</div>
       
    80                             <div class="container-footer-light-normal"><span></span></div>
       
    81                             <h3><a href="<?php echo get_permalink($archive_data->ID); ?>"><?php echo substr($archive_data->post_title, 0, 45); ?></a></h3>
       
    82                         </li>
       
    83                     <?php
       
    84                         $last_month = date("m Y", strtotime($archive_data->post_date));
       
    85                     endforeach;
       
    86                 ?>
       
    87             </ul>
       
    88 		</div>
       
    89 	</div>
       
    90 </div>
       
    91 <?php get_footer(); ?>
       
    92