WP_Query orderby random do not repeat infinite scroll – one loop

I use this solution in my functions.php /*—— order ——*/ session_start(); add_filter(‘posts_orderby’, ‘edit_posts_orderby’); function edit_posts_orderby($orderby_statement) { $seed = $_SESSION[“sem”]; if (empty($seed)) { $seed = rand(); $_SESSION[“sem”] = $seed; } $orderby_statement=”RAND(“.$seed.’)’; return $orderby_statement; } And additionaly, in the page where you show the posts, in the top of the file, i reset the session variable to … Read more

Pagination, query more pages at once

offset would skip posts, it sounds like you want the current page number * the number of posts per page- $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $posts_per_page = $paged * get_option(‘posts_per_page’); $args = array( ‘posts_per_page’ => $posts_per_page ); You’ll need to keep in mind that total number of pages in the query object will … Read more

Differnt page template for page 2 of blog feed

Not sure if you can use a complete different template but you can use different template parts using the global $page variable. Example: global $page; if ( $page == 2 ) { get_template_part( ‘page’, ‘two’ ); } else { get_template_part( ‘page’, ‘default’); } This would load the template file page-two.php or page-default.php depending on what … Read more