Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding categories to archive/blog page
  • Loading branch information
briandunnigan authored and briandunnigan committed Feb 18, 2016
1 parent e1eba48 commit c70b795
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 105 deletions.
20 changes: 17 additions & 3 deletions archive.php
Expand Up @@ -98,9 +98,23 @@ get_header(); ?>
<div class="entry-content">
<?php the_excerpt(); ?>
</div>
<!--<footer class="entry-footer clearfix">
<?php the_category(); ?>
</footer>-->
<ul class="post-categories">
<?php
$categories = get_the_category();
$separator = ' ';
$output = '';
if($categories){
foreach($categories as $category) {
if($category->name !== 'Uncategorized')
if($category->name !== 'Home-Featured')
if($category->name !== 'News Featured')
{
$output .= '<li><a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a></li>'.$separator; }
}
echo trim($output, $separator);
}
?>
</ul>
</article>

<hr />
Expand Down
68 changes: 68 additions & 0 deletions css/neag.css
Expand Up @@ -10725,6 +10725,47 @@ input[type="button"]#footers.btn-block {
border: none;
padding: 0;
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_siteorigin-panels-postloop {
/*Post Loop Widget */
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_siteorigin-panels-postloop h2 {
margin-top: 12px;
margin-bottom: 12px;
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_siteorigin-panels-postloop .content-template-date {
margin-bottom: 10px;
display: block;
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_recent-posts {
/*Recent Posts Widget */
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_recent-posts .post-date {
display: block;
font-size: 11.5px;
margin-top: 5px;
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_dpe_fp_widget {
/*Flexible Posts Widget */
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_dpe_fp_widget li {
margin-bottom: 0px;
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_rcpt {
/*Recent Custom Posts Type Widget */
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_rcpt ul {
padding-left: 0;
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_rcpt ul .rcpt_item_title {
padding: 0px;
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_rcpt ul .rcpt_item_excerpt {
margin: 0;
margin-top: 10px;
}
#page-page-builder-cards #primary #main .page .entry-content .widget.widget_rcpt ul .rcpt_item_date {
margin-top: 10px;
}
#page-page-builder-cards #primary #main .panel-grid {
margin-bottom: 0px;
margin-left: -5px;
Expand Down Expand Up @@ -10787,6 +10828,10 @@ body.page-template-page-blank .widget.widget_dpe_fp_widget ul li {
margin-bottom: 0px;
}

body.home.page-template-page-blank h3.widget-title {
margin-bottom: 15px !important;
}

body {
font-family: 'Proxima Nova', helvetica, arial, sans-serif;
}
Expand Down Expand Up @@ -11968,6 +12013,29 @@ body.archive .entry-header h1 a {
body.archive .entry-header h1.page-title {
font-size: 30px;
}
body.archive .post-categories {
list-style-type: none;
padding-left: 0;
margin-top: 15px;
}
body.archive .post-categories li {
float: left;
margin-right: 8px;
margin-bottom: 8px;
}
body.archive .post-categories li a {
color: #2d4e8b;
text-transform: uppercase;
font-size: 10px;
font-weight: 500;
padding: 3px 11px 1px;
background-color: white;
border: 1px solid #2d4e8b;
border-radius: 4px;
}
body.archive .post-categories li a:hover {
background-color: #EAEAEA;
}

/* ++++++++++++++++ Blog Continued ++++++++++++++++ */
body.page-template-page-blog .post {
Expand Down
218 changes: 116 additions & 102 deletions page-blog.php
@@ -1,103 +1,117 @@
<?php
/*
* Template Name: Blog
* Displays all published posts, in reverse chronological order.
*
* This template displays the Blog Pages when you click on news archive from the news page
*/
get_header(); ?>
<div id="page-blog">
<?php include get_template_directory().'/inc/sidebar-check.php';?>
<?php while ( have_posts() ) : the_post(); ?>
<?php include get_template_directory().'/inc/submenu-check.php'; ?>
<div class="row">
<div class="col-md-8">
<div id="primary" class="content-area subpage">
<main id="main" class="site-main" role="main">
<?php
the_content();
$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;
}
$inTheMediaObj = get_category_by_slug('neag-in-the-media');
$args = array(
'post_type' => 'post',
'category_name' => $cat,
'cat'=> '-'.$inTheMediaObj->term_id,
'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 );
if( have_posts() ):
while( have_posts() ): the_post();?>
<article id="post-<?php the_ID(); ?>" class="post type-post status-publish clearfix">
<div class="blog-thumbnail">
<?php the_post_thumbnail('thumbnail'); ?>
</div>
<header class="entry-header">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p class="text-muted"><?php the_time('F j, Y'); ?></p>
</header>
<div class="entry-content">
<?php the_excerpt(); ?>
</div>
<!--<footer class="entry-footer clearfix">
<?php the_category(); ?>
</footer>-->
</article>
<hr />

<?php endwhile; ?>


<nav class="navigation">
<?php echo paginate_links( $args ); ?>
</nav>

<?php else: ?>
<div id="post-404" class="noposts">
<p>
<?php _e('None found.','example'); ?>
</p>
</div>
<?php endif; wp_reset_query(); ?>
</main>
</div>
</div>
<?php get_sidebar(); ?>
</div>
<?php include get_template_directory().'/inc/submenu-closing-tags.php';?>
<?php endwhile; // end of the loop. ?>
</div>
<?php
/*
* Template Name: Blog
* Displays all published posts, in reverse chronological order.
*
* This template displays the Blog Pages when you click on news archive from the news page
*/
get_header(); ?>
<div id="page-blog">
<?php include get_template_directory().'/inc/sidebar-check.php';?>
<?php while ( have_posts() ) : the_post(); ?>
<?php include get_template_directory().'/inc/submenu-check.php'; ?>
<div class="row">
<div class="col-md-8">
<div id="primary" class="content-area subpage">
<main id="main" class="site-main" role="main">
<?php
the_content();
$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;
}
$inTheMediaObj = get_category_by_slug('neag-in-the-media');
$args = array(
'post_type' => 'post',
'category_name' => $cat,
'cat'=> '-'.$inTheMediaObj->term_id,
'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 );
if( have_posts() ):
while( have_posts() ): the_post();?>
<article id="post-<?php the_ID(); ?>" class="post type-post status-publish clearfix">
<div class="blog-thumbnail">
<?php the_post_thumbnail('thumbnail'); ?>
</div>
<header class="entry-header">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p class="text-muted"><?php the_time('F j, Y'); ?></p>
</header>
<div class="entry-content">
<?php the_excerpt(); ?>
</div>
<ul class="post-categories">
<?php
$categories = get_the_category();
$separator = ' ';
$output = '';
if($categories){
foreach($categories as $category) {
if($category->name !== 'Uncategorized')
if($category->name !== 'Home-Featured')
if($category->name !== 'News Featured')
{
$output .= '<li><a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a></li>'.$separator; }
}
echo trim($output, $separator);
}
?>
</ul>
</article>
<hr />

<?php endwhile; ?>


<nav class="navigation">
<?php echo paginate_links( $args ); ?>
</nav>

<?php else: ?>
<div id="post-404" class="noposts">
<p>
<?php _e('None found.','example'); ?>
</p>
</div>
<?php endif; wp_reset_query(); ?>
</main>
</div>
</div>
<?php get_sidebar(); ?>
</div>
<?php include get_template_directory().'/inc/submenu-closing-tags.php';?>
<?php endwhile; // end of the loop. ?>
</div>
<?php get_footer(); ?>
27 changes: 27 additions & 0 deletions sass/neag.scss
Expand Up @@ -1360,6 +1360,33 @@ body.archive {
font-size:30px;
}
}
.post-categories {
list-style-type: none;
padding-left:0;
margin-top:15px;

li {
float:left;
margin-right:8px;
margin-bottom:8px;


a {
color:#2d4e8b;
text-transform: uppercase;
font-size:10px;
font-weight: 500;
padding:3px 11px 1px;
background-color: white;
border:1px solid #2d4e8b;
border-radius:4px;

&:hover {
background-color:#EAEAEA;
}
}
}
}

}

Expand Down

0 comments on commit c70b795

Please sign in to comment.