Created
July 27, 2015 18:21
-
-
Save anonymous/2a1e24b10da8881a5685 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if( is_home() and !is_paged() ) : | |
// Wir teilen der Loop mit, dass entweder ein Sticky-Post, oder aber ein normaler Post angezeigt wird. | |
$args = array( | |
'posts_per_page' => 1, | |
'post__in' => get_option( 'sticky_posts' ), | |
'ignore_sticky_posts' => 1, | |
); | |
// The Query | |
$query1 = new WP_Query( $args ); | |
// Die Loop | |
while ( $query1->have_posts() ) { | |
$query1->the_post(); $do_not_duplicate = $post->ID; ?> | |
<?php // Inhalte der ersten Loop | |
<?php } ?> | |
<?php endif; ?> | |
<?php // Die zweite Loop für die weiteren Artikel. Sticky Posts werden nicht angezeigt. | |
// Die Blog-Paginierung funktioniert weiterhin, wennn wir der Loop mitteilen, wie viel Artikel angezeigt werden sollen. | |
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; | |
$exclude_query = new WP_Query( array( 'post__not_in' => get_option( 'sticky_posts' ), 'posts_per_page' => 15,'paged' => $paged ) ); | |
if ( $exclude_query->have_posts() ) : while ( $exclude_query->have_posts() ) : $exclude_query->the_post(); if ( $post->ID == $do_not_duplicate ) continue; ?> | |
<?php // Inhalt der zweiten Loop ?> | |
<?php wp_reset_postdata(); ?> | |
<?php endwhile; endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment