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( 'o', $date_to_fetch ),
'week' => date( 'W', $date_to_fetch ),
),
),
'post_status' => 'publish'
);
query_posts($query_string);
If you are working with date( 'W' )
, you should always be working with date( 'o' )
instead of date( 'Y' )
, because at the beginning of a year it is possible that you are still in a week which is accounted to the past year. For this see the documentation of the date function: http://php.net/manual/de/function.date.php
Related Posts:
- How to fix pagination for custom loops?
- Pagination not working on home page
- WordPress category & taxonomy loop with pagination
- How do I prevent one of two multiple loops from repeating on a second page?
- Two custom loops, pagination, offset
- Previous and Next Post link doesn’t work
- Pagination adding extra posts only on page 2
- Output shows a page instead of a list of blog postings
- multiple loops with pagination on the same page
- Enable infinite scroll on single.php [closed]
- How to paginate this custom loop? [duplicate]
- Make a custom loop inside single.php with pagination
- Why do I get `Call to a member function have_posts() on a non-object `? [closed]
- Pagination gives extra page with no results
- Get Pagination (WP-PageNavi) not to work
- Create static front-page with 3-5 recent posts
- How to get an array of years from all of the search results, and use it to filter by year the paginated loop?
- Loop first six posts in carousel, next eight in grid
- Complex query and posts pagination
- Why only one post (and no pagination) on this variation of the loop?
- Calling & display certain product category loop and pagination on the homepage
- Make blog page show 10 on first page, 9 on every other page
- Detect if current page is front page within custom query
- Pagination for multiple loops
- How to fix pagination for custom loops?
- How can I paginate this?
- Genesis multiple category custom loop 404s after first page
- How to fix pagination for custom loops?
- Pagination – works on local but not live dev!
- Page-loop is looping content from custom loops on the same site. How to avoid that?
- How do I paginate a get_posts() request inside another page loop (Paginating childpages)
- Pagination on Single Post
- How to get my loop to paginate?
- Distribute Gallery Images Every nth in Loop
- How to exclude or filter password protected posts when using next_post_link() previous_post_link
- How to append a query string to pagination?
- How do I get my loop.php to properly paginate?
- First archive page with a few posts
- Pagination broken after using 2 loops to show content
- Pagination on custom post type on front-page.php
- How do I put my frontpage featured image in a page template for home.php?
- I have broke my pagination, same posts on all pages (index.php)
- Problem with Front-Page.php loading recent posts
- How can this multiple loop have pagination as described?
- Display more than 10 posts on author.php file
- static page with multiple loops breaks post pagination
- Pagination for two loops
- Skip 5 latest post while paging?
- Why does my WP_Query pagination on a custom page.php only loads the homepage?
- How to insert content before pagination in loop?
- Pagination on a underscore custom theme
- WordPress multiple loops with default pagination
- How to fix pagination for custom loops?
- Style first 3 posts differently and use a 2nd loop to get rest of posts / offset and pagination broken
- Custom loop not working in singular.php, working in other pages
- Alternative layout the loop
- How to fix pagination for custom loops?
- Adding pagination to WP_Query [duplicate]
- How to fix pagination for custom loops?
- How to fix pagination for custom loops?
- Why is my pagination showing up?
- Displaying posts limit: can’t get pagination to display [duplicate]
- Paged homepage – requirements?
- Home page loop with pagination problem
- WooCommerce custom loop pagination on front page
- posts_nav_link() not working on index.php
- Custom Page Template and Category Exclusion
- repeating posts on 2nd page to posts
- Limitless amount of posts in custom archive page
- Same posts within a paginated page
- Multiple loop with pagination in same page
- Insert multiple custom components after x-number of posts
- Show scheduled posts in archive page
- Display different number of posts from one category on the different pages
- post__in – Placing content from a foreach loop inside of an array
- add_filter() doesn’t work in loop
- The Loop in Static Page
- Loop posts only excluding first post
- Customize WooCommerce Product Images (Placement and size) [closed]
- Create a loop that gets pages with their template
- How to check if a post exist?
- Why cant you place the Loop outside of the index.php?
- sticky post in custom loop
- On single.php, fetch 2 posts created after and 2 posts created before in relation to the actual post (using menu_order)
- Pagination w/Static Front Page
- Exclude page name from loop
- PHP if post is already displayed, then
- How to style first post differently with ‘get_template_part’?
- in Foreach Loop the Description is not showing?
- WordPress shortcode in content, output in sidebar?
- Using variable in WordPress loop as criteria
- Get_template_part() problem with the_content()
- Insert content above an embedded video inside Wordress’ php the_content
- the loop printing post in one grid
- Pagination on Custom Loop
- show posts from one category with comments only
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- Loop from another WP site onto mine
- Wrap every 2 divs in row – for each loop [closed]
- How to add class to the last image of the last post in a loop