Skip to content

Instantly share code, notes, and snippets.

Created July 27, 2015 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2a1e24b10da8881a5685 to your computer and use it in GitHub Desktop.
Save anonymous/2a1e24b10da8881a5685 to your computer and use it in GitHub Desktop.
<?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