Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
<?php
/*
Template Name: Posts
*/
get_header(); ?>
<div class="row" id="primary">
<div class="span9 posts">
<?php
//query_posts('post_type=post&post_status=publish&paged='. get_query_var('paged'));
$view = get_post_meta( get_the_ID(), 'view', true );
$cat = get_post_meta( get_the_ID(), 'categories', true );
$tag = get_post_meta( get_the_ID(), 'tags', true );
$authornames = get_post_meta( get_the_ID(), 'authors', true );
$authorsArr = explode(",", $authornames);
if( array_key_exists(1, $authorsArr) ){
$authorsStr = '';
foreach( $authorsArr as $a ){
$user = get_user_by('slug', $a);
$id = $user->ID;
$authorsStr .= $id.',';
}
$author = rtrim($authorsStr, ',');
} else {
$author = get_user_by('slug', $authornames)->ID;
}
$args = array(
'post_type' => 'post',
'category_name' => $cat,
'tag' => $tag,
'author' => $author,
'post_status' => 'publish',
'paged' => get_query_var('paged'),
);
if( isset($args) ){
$pattern = '#[a-zA-Z|~`!@\#$%^&*()_+=|\\}\][{\'/;\-":?>.<]#';
$arr = array('category_name'=>$cat, 'tag'=>$tag, 'author'=>$author);
foreach( $arr as $k=>$v ){
if( empty($v) ){
continue;
}
if( $k == 'author' ){
$pattern = '#[0-9|~`!@\#$%^&*()_+=|\\}\][{\'/;\-":?>.<]#';
}
if( preg_match($pattern, $v) ){
$args[$k] = $v;
} else {
echo '<p>Invalid input in field: "'.$k.'"</p>';
}
}
}
query_posts( $args );
?>
<?php if( have_posts() ): ?>
<?php if ($view == "table") { ?>
<div class="content">
<table class="table table-responsive table-striped">
<thead>
<tr>
<th>Date</th>
<th>To</th>
<th>Subject</th>
</tr>
</thead>
<tbody>
<?php } ?>
<?php while( have_posts() ): the_post(); ?>
<?php if ($view == "table") { ?>
<tr>
<td><?php the_date('n/j/y');?></td>
<td><?php $to = get_post_meta( get_the_ID(), 'to', true ); if ($to) {
echo $to;
} else {
echo 'Missing Custom Field "to"';
}?></td>
<td><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></td>
</tr>
<?php } else { ?>
<?php
if( has_post_format('link') ){
get_template_part( 'post-format-link' );
} else {
?>
<div class="post content clearfix">
<div class="post-header">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
</div>
<div class="post-content clearfix">
<?php the_content(); ?>
</div>
<div id="social-buttons"> Share on: <a href="http://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>"><img src="<?php echo get_stylesheet_directory_uri().'/imgs/asset.f.logo.lg.png';?>" alt="facebook" />Facebook</a><a href="http://twitter.com/share?url=<?php the_permalink(); ?>&text=<?php echo get_the_excerpt(); ?>"><img src="<?php echo get_stylesheet_directory_uri().'/imgs/twitter-bird-white-on-blue.png';?>" alt="Twitter" />Twitter </a><a href="http://www.linkedin.com/shareArticle?url=<?php the_permalink(); ?>&title=<?php echo get_the_title(); ?>&summary=<?php echo get_the_excerpt(); ?>&source=<?php the_permalink(); ?>"> <img src="<?php echo get_stylesheet_directory_uri().'/imgs/linkedin.png';?>" alt="LinkedIn" />LinkedIn</a> </div>
<div class="post-meta">
<?php the_date( 'F j, Y', '<span class="post-date"><i class="icon-calendar"></i>', '</span>' ); ?>
<span class="post-author"><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><i class="icon-user"></i><?php the_author_meta( 'display_name' ); ?></a></span>
<?php
// PHP Request: If the_tags is empty, do not generate the HTML. I don't want the labels and markup making empty space when there are no tags.
the_tags( '<span class="post-tags"><i class="icon-tags"></i>', ', ', '</span>' );
?>
</div>
</div>
<?php
}
?>
<?php }?>
<?php endwhile; ?>
<?php if ($view == "table") { ?>
</tbody>
</table>
</div>
<?php } ?>
<div class="navigation">
<span class="older"><?php next_posts_link(__('&laquo; Older','example')) ?></span> <span class="newer"><?php previous_posts_link(__('Newer &raquo;','example')) ?></span>
</div><!-- /.navigation -->
<?php else: ?>
<div id="post-404" class="noposts">
<p><?php _e('None found.','example'); ?></p>
</div><!-- /#post-404 -->
<?php endif; wp_reset_query(); ?>
</div>
<div class="span3">
<?php get_sidebar('Sidebar'); ?>
</div>
</div>
<?php get_footer(); ?>