• Hello all, how do I exclude sticky posts from this code without ruining this code
    <div id=”primary” <?php mb_primary_attr(); ?> role=”main”>
    <?php
    $sticky = get_option( ‘sticky_posts’ );
    $featured = new WP_Query( array(
    ‘posts_per_page’ => 1,
    ‘post__in’ => $sticky,
    ‘ignore_sticky_posts’ => 1
    ) );

    global $paged;
    if ( ! empty( $sticky[0] ) && is_home() && 2 > $paged ) {
    ?>
    <div id=”featured” class=”row”>
    <?php
    while ( $featured->have_posts() ) : $featured->the_post();
    global $mb_content_area;
    $mb_content_area = ‘main’;
    get_template_part( ‘content’, get_post_format() );
    endwhile;

    wp_reset_postdata();
    ?>
    </div>
    <?php
    }

    if ( have_posts() ) : ?>
    <div class=”row”>
    <?php
    while ( have_posts() ) : the_post();
    global $wp_query;
    $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var(‘paged’) : 1;
    $grid = mb_theme_options( ‘grid’ );
    $posts_per_page = mb_theme_options( ‘number’ );
    $count = $wp_query->current_post;
    $total = $wp_query->post_count – 1;
    $border = ( 3 == $grid && 1 == $paged ) ? ‘<div class=”c12 border”><span></span></div>’ : ”;

    $two_open_tag = ( ( ( 2 == $grid || 3 == $grid) && 1 == $count && 1 == $paged ) || ( 2 == $grid && 0 == $count && 1 < $paged ) ) ? ‘<!– 2 cols –><div class=”two-col-wrapper”>’ : ”;
    $two_close_tag = ( ( 2 == $grid && $total == $count ) || ( 3 == $grid && ( 2 == $count || ( $total == 1 && 1 == $count ) ) && 1 == $paged ) ) ? ‘</div><!– eof 2 cols –>’ : ”;
    $three_open_tag = ( ( 3 == $grid && 3 == $count && 1 == $paged ) || ( 4 == $grid && 1 == $count && 1 == $paged ) || ( ( 3 == $grid || 4 == $grid ) && 0 == $count && 1 < $paged ) ) ? $border . ‘<!– 3 cols –><div class=”three-col-wrapper”>’ : ”;
    $three_close_tag = ( $total == $count && ( ( 3 == $grid && $total >= 3 ) || ( 4 == $grid && $total >= 1 ) ) ) ? ‘</div><!– eof 3 cols–>’ : ”;

    if ( 1 < $posts_per_page ) {
    echo $two_open_tag;
    echo $three_open_tag;
    }

    global $mb_content_area;
    $mb_content_area = ‘main’;
    get_template_part( ‘content’, get_post_format() );

    if ( 1 < $posts_per_page ) {
    echo $two_close_tag;
    echo $three_close_tag;
    }
    endwhile;
    ?>
    </div>
    <?php
    mb_pagination();

    else :
    ?>
    <article id=”post-0″ class=”post no-results not-found”>

    <?php if ( current_user_can( ‘edit_posts’ ) ) :
    // Show a different message to a logged-in user who can add posts.
    ?>
    <h1 class=”entry-title”><?php _e( ‘No posts to display’, ‘magazine-basic’ ); ?></h1>

    <div class=”entry-content”>
    <p><?php printf( __( ‘Ready to publish your first post? Get started here.’, ‘magazine-basic’ ), admin_url( ‘post-new.php’ ) ); ?></p>
    </div><!– .entry-content –>

    <?php
    else :
    get_template_part( ‘content’, ‘none’ );
    endif; // end current_user_can() check
    ?>

    </article><!– #post-0 –>
    <?php

    endif;
    ?>
    </div><!– #primary –>

    <?php get_footer(); ?>

The topic ‘How to exclude sticky posts from this code’ is closed to new replies.