Answer the question
In order to leave comments, you need to log in
Does it make sense to limit the length of varchar?
Well actually a subject. I constantly freak out about this. Toli leave 32 bytes for a name, for example, or MD5 hashes, roofing felts 255 and do not suffer, but limit the length programmatically. Will such rows take up extra bytes when stored and will the index increase in size?
The same goes for other types of data. For example int (I am aware of the int type table and the number of bytes, it is an artificial limitation)
Answer the question
In order to leave comments, you need to log in
Replace
wp_pagenavi();
on
the_posts_pagination();
If so, then add this to functions.php (at the end):
add_action('template_redirect', function() {
if ( is_home() || is_front_page() ) {
global $wp_query;
$page = (int) $wp_query->get('page');
if ( $page > 1 ) {
// convert 'page' to 'paged'
$query->set( 'page', 1 );
$query->set( 'paged', $page );
}
// prevent redirect
remove_action( 'template_redirect', 'redirect_canonical' ); // убиваем редирект от /page/2
}
}, 0 );
Для Вас это должно подойти:
<?php while ( have_posts() ) : the_post();
$paged_string = is_home() || is_front_page() ? 'page' : 'paged';
$paged = get_query_var( $paged_string ) ? get_query_var( $paged_string ) : 1;
$args = array(
'paged' => $paged,
'post_type' => 'post'
);
$all_posts = new WP_Query( $args );
$style = get_post_meta( $post->ID, 'krown_blog_style', true );
while ( $all_posts->have_posts() ) : $all_posts->the_post();
if ( $style == 'blog-standard-author' ) {
get_template_part( 'content-author' );
} else {
get_template_part( 'content' );
}
endwhile;
wp_pagenavi( array( 'query' => $all_posts ) );
<?php wp_reset_postdata(); ?>
Обязательно нужно ограничивать!
То же самое в int если знаете что числа будут небольшие - используйте smallint
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question