Skip to content

Instantly share code, notes, and snippets.

@hborrelli1
Last active March 29, 2019 15:37
Show Gist options
  • Save hborrelli1/b8eea59796a4afc8cae3ef60f83fdbd1 to your computer and use it in GitHub Desktop.
Save hborrelli1/b8eea59796a4afc8cae3ef60f83fdbd1 to your computer and use it in GitHub Desktop.
Custom Loop for WP posts
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package The7
* @since 1.0.0
*/
// File Security Check
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$config = presscore_config();
remove_action( 'presscore_before_main_container', 'presscore_page_title_controller', 16 );
get_header('posts');
?>
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 5,
'facetwp' => true,
);
$loop = new WP_Query( $args );
?>
<div id="content" class="content" role="main">
<h4 class="recent-blog-posts-title">Recent Blog Posts</h4>
<!-- <div class="posts-wrapper facetwp-template"> -->
<div class="posts-wrapper">
<?php
if ( $loop->have_posts() ) : ?>
<div class="articles-list facetwp-template">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="post-wrap">
<a class="post-anchor" href="<?php the_permalink(); ?>">
<div class="blog-image-wrap" style="background-image:url(<?php echo the_post_thumbnail_url(); ?>);">
<div class="blog-image-overlay"></div>
</div>
<div class="blog-content-wrap">
<span class="date"><?php echo get_the_date(); ?></span>
<?php the_title('<h3>', '</h3>'); ?>
<div class="blog-excerpt"><?php echo the_excerpt(); ?></div>
</div>
</a>
</div>
<?php endwhile ?>
<?php else : ?>
<?php get_template_part( 'no-results', 'blog' ) ?>
<?php endif ?>
</div>
<?php // dt_paginator() ?>
</div>
<button class="fwp-load-more">Load more</button>
</div>
<?php // do_action( 'presscore_after_content' ) ?>
<?php echo do_shortcode('[facetwp facet="search_facet_blog_posts"]'); ?>
<?
get_footer('posts');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment