This repository has been archived by the owner. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
hri/page-blog.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
278 lines (199 sloc)
10.2 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Blog - Latest News | |
*/ | |
get_header(); ?> | |
<div id="body-container"> | |
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> | |
<div class="custom-span8"> | |
<div class="section-title text-serif"> | |
<?php $key="section-title"; echo get_post_meta($post->ID, $key, true); ?> | |
</div> | |
<h1 class="page-title"><?php the_title(); ?></h1> | |
<hr class="title-hr" /> | |
<div class="span8 no-marg-left"> | |
<div class="post content clearfix" id="post-<?php the_ID(); ?>"> | |
<?php $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1; | |
if($paged == 1){ | |
?> | |
<div class="featured-archive"> | |
<?php | |
$args = array('category_name' => 'featured-blog-article', | |
'posts_per_page' => 1, | |
'orderby' => 'post-date', | |
); | |
$the_query = new WP_Query( $args ); | |
?> | |
<?php if ( $the_query->have_posts()): | |
while ( $the_query->have_posts() ) { | |
$the_query->the_post(); | |
?> | |
<div class="featured-archive-image-container"> | |
<div class="featured-archive-image"> | |
<img src="<?php $key="featured-image-square"; echo( get_post_meta($post->ID, $key, true)); ?>" /> | |
</div> | |
</div> | |
<div class="featured-archive-content"> | |
<h3 class="text-serif"><a href=" <?php the_permalink(); ?>"><?php the_title();?></a></h3> | |
<h4>BY <?php the_author(); ?> </h4> | |
<hr class="dotted" /> | |
<p class="archive-date"><img src="<?php bloginfo('template_url'); ?>/img/icon-calendar-grey.png"/> <?php the_date(); ?> </p> | |
<ul> | |
<li><img src="<?php bloginfo('template_url'); ?>/img/icon-tag-grey.png"/> | |
<?php the_category(', '); ?> </li> | |
</ul> | |
<div class="clear"></div> | |
<hr class="dotted-bottom" /> | |
<div class="entry"> | |
<?php the_excerpt('<p class="serif">Read the rest of this page »</p>'); ?> | |
</div> | |
</div> | |
<?php } ?> | |
<?php else: ?> | |
<p><?php _e('Sorry, no recent news.'); ?></p> | |
<?php endif; ?> | |
<div class="clear"></div> | |
</div> | |
<?php } ?> | |
<div class="blog-squares-wrapper"> | |
<?php | |
$posts_per_page = 4; | |
// $offset = ( $paged - 1 ) * $posts_per_page; | |
//if($paged > 1){ | |
// $offset = ( $paged - 1 ) * $posts_per_page; | |
// $posts_per_page = 6; | |
// } | |
//if($paged > 2){ | |
// $offset = ( $paged - 2 ) * $posts_per_page + 4; | |
// } | |
$args = array('category_name' => 'blog', | |
'posts_per_page' => $posts_per_page, | |
//'offset' => $offset+1, | |
'orderby' => 'post-date', | |
'paged' => $paged); | |
$the_query = new WP_Query( $args ); | |
?> | |
<?php if ( $the_query->have_posts()): | |
while ( $the_query->have_posts() ) { | |
$the_query->the_post(); | |
?> | |
<div class="blog-story-preview"> | |
<div class="blog-story-image-container"> | |
<div class="blog-story-image"> | |
<?php echo get_the_post_thumbnail($post->ID, array(320,320) , 'medium'); ?> | |
</div> | |
</div> | |
<div class="blog-story-preview-content"> | |
<h3><a href=" <?php the_permalink(); ?>"><?php if (strlen($post->post_title) > 60) { | |
echo substr(the_title($before = '', $after = '', FALSE), 0, 60) . '...'; } else { | |
the_title(); | |
} ?></a></h3> | |
<h4>BY <?php the_author(); ?> </h4> | |
<hr class="dotted-bottom" /> | |
<p class="archive-date"><img src="<?php bloginfo('template_url'); ?>/img/icon-calendar-green.png"/> <?php the_date(); ?> </p> | |
<ul class="category-blog"> | |
<li><img src="<?php bloginfo('template_url'); ?>/img/icon-tag-green.png"/> | |
<?php | |
$categories = get_the_category(); | |
$separator = ', '; | |
$output = ''; | |
if($categories){ | |
$i=0; | |
foreach($categories as $category) { | |
$i++; | |
if($i > 3) break; | |
$output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator; | |
} | |
echo trim($output, $separator); | |
} | |
?> | |
</li> | |
</ul> | |
</div> | |
</div> | |
<?php } ?> | |
</div> | |
<div class="clear"></div> | |
<div class="blog-pagination"> | |
<?php | |
if($the_query->found_posts > 4){ | |
$total = ceil(($the_query->found_posts+2)/6); | |
} | |
else{ | |
$total = 1; | |
} | |
$big = 999999999; // need an unlikely integer | |
echo paginate_links( array( | |
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), | |
'format' => '?paged=%#%', | |
'current' => max( 1, get_query_var('paged') ), | |
'total' => $total, | |
'prev_text' => __('‹ Previous'), | |
'next_text' => __('Next ›'), | |
'show_all' => False, | |
'end_size' => 0, | |
'mid_size' => 1 | |
) ); | |
?> | |
<?php else: ?> | |
<p><?php _e('Sorry, no recent news.'); ?></p> | |
<?php endif; ?> | |
</div> | |
</div> | |
</div> | |
<?php endwhile; endif; ?> | |
</div> | |
</div> | |
<div class="sidebar"> | |
<span class="search-form"><?php get_search_form(); ?></span> | |
<?php $sidebar = get_post_meta($post->ID, 'sidebar-a', true); | |
get_sidebar($sidebar); | |
?> | |
<?php | |
$category = get_category_by_slug( 'blog' ); | |
$args = array ( | |
'title_li' => __( 'Blog Categories' ), | |
'hide_empty' => 0, | |
'use_desc_for_title' => 0, | |
'child_of' => $category->term_id | |
); | |
wp_list_categories( $args ); ?> | |
<h2 class="widget-title">Archives</h2> | |
<div class="panel-group" id="accordion"> | |
<?php $args = array ( | |
'type' => 'monthly', | |
'echo' => 0, | |
); | |
$archives = wp_get_archives( $args); | |
$archives = explode('</li>',$archives); | |
$year = 0; | |
foreach($archives as $archive){ | |
$newyear = substr($archive,-8,4); | |
if(!preg_match('/^\d{4}$/',$newyear)){ | |
continue; | |
} | |
if($year != $newyear){ | |
if($year != 0){ | |
echo '</div></div>'; | |
} | |
echo '<div class="panel panel-default"> | |
<div class="panel-heading"><p class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#'.$newyear.'">'.$newyear.'</a></p></div>'; | |
echo '<div id="'.$newyear.'" class="collapse'; | |
if($year == 0) echo ' in'; | |
echo '">'; | |
$year = $newyear; | |
} ?> | |
<?php | |
$archive = str_replace(' '.$year,'',$archive); | |
$archive = str_replace('<li>','',$archive); | |
echo '<div class="panel-body">'; | |
echo '<ul class="archive-list"><li>'.$archive.'</li></ul>'; | |
echo '</div>'; | |
} | |
echo '</div></div>'; | |
?> | |
</div> | |
</div> | |
</div> | |
</div> | |
<?php get_footer(); ?> |