Commit ce4cb720 authored by numeroteca's avatar numeroteca

#28 crea plantilla blog y paginación

parent 7e77a65e
......@@ -97,10 +97,33 @@ if ( ! function_exists( 'colormag_top_header_bar_display' ) ) :
endif;
// ends modifiying top bar
// Describe what it does
add_action("after_setup_theme", function () {
load_theme_textdomain( 'colormag-child', get_stylesheet_directory() . '/languages' );
}, 5);
}, 5);
//formated pagination for bootstrap from http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/
function custom_pagination() {
global $wp_query;
$big = 999999999; // need an unlikely integer
$pages = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'prev_next' => false,
'type' => 'array',
'prev_next' => TRUE,
'prev_text' => __('<'),
'next_text' => __('>'),
) );
if( is_array( $pages ) ) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '<ul class="pagination pagination-lg">';
foreach ( $pages as $page ) {
echo "<li>$page</li>";
}
echo '</ul>';
}
}
<?php
/* Template Name: Blog page */
get_header(); ?>
<?php
$args = array(
'ignore_sticky_posts' => 1,
'posts_per_page'=> 15
);
if ( $paged > 1 ) {
$args['paged'] = $paged;
}
$wp_query = new WP_Query($args);
$wp_count = $wp_query->post_count; //The number of posts being displayed
?>
<?php do_action( 'colormag_before_body_content' ); ?>
<div id="primary">
<div id="content" class="clearfix">
<?php if ($wp_query->have_posts() ) :
$count = 0;
while ( $wp_query->have_posts()) : $wp_query->the_post();
?>
<?php get_template_part( 'content', '' ); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<hr>
Pagination
<hr>
<div style="clear:both;">
<?php echo custom_pagination(); ?>
</div>
</div><!-- #content -->
</div><!-- #primary -->
<?php colormag_sidebar_select(); ?>
<?php do_action( 'colormag_after_body_content' ); ?>
<?php get_footer(); ?>
......@@ -363,3 +363,42 @@ img {
img:hover {
opacity: 0.4 !important;
}
/* Pagination */
.pagination-lg > li:first-child > a, .pagination-lg > li:first-child > span {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
.pagination-lg > li > a, .pagination-lg > li > span {
padding: 10px 16px;
font-size: 18px;
line-height: 1.3333333;
}
.pagination > li {
display: inline;
}
.pagination > li > a, .pagination > li > span {
position: relative;
float: left;
padding: 6px 12px;
margin-left: -1px;
line-height: 1.42857143;
color: #337ab7;
text-decoration: none;
background-color: #fff;
border: 1px solid #ddd;
}
.pagination {
display: inline-block;
padding-left: 0;
margin: 20px 0;
border-radius: 4px;
}
.pagination-lg > li:last-child > a, .pagination-lg > li:last-child > span {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
.page-numbers.current {
background:lightgray;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment