Skip to content

Instantly share code, notes, and snippets.

@eliasfaical
Created June 8, 2020 16:08
Show Gist options
  • Save eliasfaical/1f8d13b31f7abae696f6ae4f30f00c4f to your computer and use it in GitHub Desktop.
Save eliasfaical/1f8d13b31f7abae696f6ae4f30f00c4f to your computer and use it in GitHub Desktop.
<?php
/**
* Template Name: Blog
*/
get_header();
?>
<main id="main" class="site-main innerPage">
<section class="banner-innerPage" style="background-image: url(<?php echo get_template_directory_uri(); ?>/assets/images/banner-conteudo.jpg)">
<div class="container text-center">
<?php
the_title('<h1>', '</h1>');
?>
</div>
</section>
<section class="section-conteudo">
<div class="container">
<div class="row">
<?php
$args_blog = array(
'post_type' => 'post',
'posts_per_page' => 8,
'paged' => get_query_var('paged') ? get_query_var('paged') : 1
);
$query_blog = new WP_Query( $args_blog );
if( $query_blog->have_posts() ) :
while( $query_blog->have_posts() ) : $query_blog->the_post();
?>
<div class="col-md-4">
<div class="item-noticia">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="d-block">
<img src="<?php the_post_thumbnail_url('post-blog'); ?>" alt="<?php the_title(); ?>" class="img-fluid">
</a>
<div class="box-inner">
<span class="cat"><?php the_category(); ?></span>
<?php
// Título
the_title('<h3>','</h3>');
// Data
echo '<span><i class="fas fa-calendar-check"></i> '. get_the_date('d/m/Y') .'</span>';
$excerpt = get_the_content();
echo string_limit_words($excerpt, 18) .' [...]';
?>
<p><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="btn btn-yellow">Leia mais</a></p>
</div>
</div>
</div>
<?php
endwhile;
endif;
echo '<div class="pagination">';
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $query_case->max_num_pages
) );
echo '</div>';
wp_reset_query();
?>
</div>
</div>
</section>
</main>
<?php
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment