Problem when I try to insert pagination

Thanks for @PieterGoosen for his help, I found the solution for my problem. In my functions.php, I construct the next function: function mod_query($query){ if ( !is_admin() && $query->is_main_query() && $query->is_category(‘6’)){ //My Category ID $query->set(‘posts_per_page’,2); } } add_action(‘pre_get_posts’,’mod_query’); And I needed one file, category-blog.php where I build my html code and use the php code if … Read more

Frontpage pagination by week

Use the page number to calculate a new date to get the week to fetch: $page = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $date_to_fetch = time() – ( 604800 * ( $page – 1 ) ) ); $query_string = array( ‘post_type’ => ‘post’, ‘date_query’ => array( array( ‘year’ => date( … Read more

next_posts_link(); & previous_posts_link(); not working properly

I did this and its working as expected. Please close this question <div class=”post-content”> <?php // set the “paged” parameter (use ‘page’ if the query is on a static front page) $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $the_query = new WP_Query( ‘posts_per_page=5&post_type=blog&paged=’ . $paged ); if($the_query->have_posts()) { while($the_query->have_posts()) … Read more

WP_Query custom order and pagination

You want to orderby ‘date’ not by ‘meta_value_num’ because it is to order numerically. So if you were ordering items by their price, then you would want to use ‘meta_value_num’. The meta_key ‘news_date’ is most likely in date format. You should also cast the meta_value to DATE using ‘meta_type’ => ‘DATE’. $args = array( ‘post_type’ … Read more

error code: 521