Skip to content

Instantly share code, notes, and snippets.

@nicknmejia
Created October 23, 2017 21:01
Show Gist options
  • Save nicknmejia/15926f6a0afa1c18d223b4f47c9ebed0 to your computer and use it in GitHub Desktop.
Save nicknmejia/15926f6a0afa1c18d223b4f47c9ebed0 to your computer and use it in GitHub Desktop.
SLR Lounge Blog Front End
<?php
/**
* Blog Posts page archive
*/
get_header();
$args = array(
'numberposts' => 2,
'post_type' => ['post', 'workshop'],
'post_status' => 'publish',
'order' => 'DESC',
);
$recent_posts = wp_get_recent_posts( $args, OBJECT_K );
$slots_in_use = \SLR\HubArticleListingController::GetInstance()->GetFeaturedSlotsInUse(\SLR\HubArticleListingController::GetInstance()->GetFeaturedArticlesIds());
$featured_article_1 = $recent_posts[0];
$featured_article_2 = $recent_posts[1];
if(in_array('slot1', $slots_in_use) && !in_array('slot2', $slots_in_use)){
$featured_article_2 = $recent_posts[0];
}
?>
<div id="hub" class="constrain-xl">
<div class="main-blog-features column-12">
<?php include('components/Blog__FeaturedArticle/Blog__FeaturedArticleDisplay.php'); ?>
</div>
<div class="column-12">
<?php include('components/Blog__ArticleFeatureNarrow/Blog__ArticleFeatureNarrow.php'); ?>
</div>
<div class="row gutters">
<div class="column-9">
<?= \SLR\HubArticleListingController::RenderView( [
'cat' => get_query_var( 'cat' ),
'tag' => get_query_var( 'tag_id' ),
] ) ?>
</div>
<?php include('components/Sidebar/Sidebar.php') ?>
</div>
</div>
<?php get_footer(); ?>
<?php
$args = array(
'meta_key' => '_is_hub_slot',
'meta_value' => 'slot1',
);
$query = new \WP_Query($args);
if(!empty($query->posts)){
$featured_article_1 = $query->posts[0];
}
$excerpt = ( get_the_excerpt($featured_article_1) != '' ? truncate(get_the_excerpt($featured_article_1), 120) : truncate(wp_trim_excerpt( $featured_article_1->post_content)));
$featured_video_url = get_post_meta($featured_article_1->ID, 'featured_video_url', true);
?>
<div class="blog__featured-article-display">
<?php if($featured_video_url) : ?>
<div class="video-display">
<?= wp_oembed_get($featured_video_url); ?>
</div>
<?php else : ?>
<a href="<?php echo get_permalink($featured_article_1->ID) ?>" class="article-image">
<img class="fill-aspect-ratio" src="<?php echo get_the_post_thumbnail_url($featured_article_1); ?>" alt="">
</a>
<?php endif; ?>
<div class="article-descriptor">
<span class="main-tag"><?php the_top_category($featured_article_1->ID) ?></span>
<a href="<?php echo get_permalink($featured_article_1->ID) ?>" class="title"><?= $featured_article_1->post_title ?></a>
<div class="author">By <a href="<?php echo get_author_posts_url( $featured_article_1->post_author ); ?>" class="author-weight"><?php echo get_the_author_meta('display_name', $featured_article_1->post_author); ?></a> on <?= get_the_date('', $featured_article_1) ?></div>
<div class="blurb"><?= wp_strip_all_tags($excerpt) ?></div>
<?php if((int)$featured_article_1->comment_count >= 1): ?>
<a href="<?php get_comments_link($featured_article_1->ID) ?>" class="comments"><?= slr_icon('comment') ?> <?= $featured_article_1->comment_count ?> <?= (($featured_article_1->comment_count == 1) ? 'Comment' : 'Comments') ?></a>
<?php endif; ?>
</div>
</div>
<?php
$post = get_post();
?>
<div class="blog__single-article-rectangle">
<div class="article-image-container">
<a href="<?php the_permalink(); ?>" class="article-image">
<?php the_post_thumbnail( 'width-400', ['class' => 'fill-aspect-ratio', 'sizes' => '(max-width: 649px) 100vw, 405px'] ); ?>
<?php if(is_time_new(get_the_date(), 24)): ?>
<div class="new-tag">New</div>
<?php endif; ?>
</a>
</div>
<div class="article-descriptor">
<span class="main-tag"><?= ($post->post_type == 'workshop' ? '<a href="/workshop" class="category">workshop</a>' : the_top_category()) ?></span>
<a href="<?php the_permalink(); ?>" class="title"><?php the_title(); ?></a>
<div class="author">By <a href="<?php the_author_meta('url'); ?>" class="author-weight"><?php the_author(); ?></a> on <?= get_the_date() ?></div>
<div class="blurb"><?= truncate(wp_strip_all_tags(get_the_excerpt()), 90); ?></div>
<?php if((int)get_comments_number() > 1): ?>
<a href="<?php comments_link(); ?>" class="comments"><?= slr_icon('comment') ?> <?php comments_number( 'No comments', '1 Comment', '% Comments' ); ?></a>
<?php endif; ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment