Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $posts = $wp_query->posts; // Gets all post data from the main query
- $c = []; // Going to hold an array of new keys for later use
- if ( have_posts() ) {
- $count = 0; //Start the counter
- $ppp = get_option('posts_per_page'); // Gets the backend posts per page option set. Will be used in conjustion with the counter
- while ( have_posts() ) {
- the_post();
- if(has_tag('test')) { // This will be the tag to test against, your desired tag
- $c[] = $count++;
- }else{
- $c[] = $ppp + $count++; // Adds posts per page value to each count to advance posts without desired tag past desired tag
- }
- }
- }
- $posts_reordered = array_combine( $c, $posts ); // Reset each post from main query's key with the new keys created by $c
- $sort_posts = ksort($posts_reordered); // Sort the new array according to key
- /* ?><pre><?php var_dump($posts_reordered); ?></pre><?php */ // Uncomment to dump your array to get objects
- foreach ($posts_reordered as $value) {
- echo '<h1>' . $value->post_title . '</h1>';//This will be your new loop
- echo get_the_post_thumbnail( $value->ID);
- echo apply_filters( 'the_content', $value->post_content );
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement