Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I recently updated to wordpress 3.7 and all of a sudden my posts page stopped working . it shows nothing and opens up a blank page . there is small code on that page and it stopped working . It was using query_posts to get the posts but now a bank page shows up .

the code

    <? query_posts ('cat=-103&posts_per_page=1') ?>

 <? while (have_posts ()) { the_post ();  ?>

    <div class="reu-sec">

        <h2><a href="<? the_permalink() ?>"><? the_title (); ?><span class="sbttlmn"> &nbsp <?= get_post_meta (get_the_ID(), 'sub-title', true); ?></span></a></h2>

        <div class="desc">

            <? //the_content ('[More]'); ?>

            <div class="reu-prev1"><a href="<? the_permalink() ?>"><img src="<?= get_post_meta (get_the_ID(), 'image', true); ?>"/></a></div>

            <div class="reu-prev2"><a href="<? the_permalink() ?>"><img src="<?= get_post_meta (get_the_ID(), 'image2', true); ?>"/></a></div>

            <div class="reu-prev3"><a href="<? the_permalink() ?>"><img src="<?= get_post_meta (get_the_ID(), 'image3', true); ?>"/></a></div>

        </div>

        <div style="clear: both"></div>

    </div>

<?php }  ?>
share|improve this question
    
Why are you using query_posts()? –  Chip Bennett Oct 29 '13 at 22:55
    
i found that only non login user are facing problem . the users who login are able to see the posts –  user1001176 Oct 29 '13 at 23:06
1  
Well, nothing in the code you've posted is specific to logged in vs. non-logged in users. You'll need to find and post the code related to logged in users. –  Chip Bennett Oct 29 '13 at 23:11

1 Answer 1

Get rid of query_posts() in your template file. Instead, you need to filter the main query object, via pre_get_posts.

The following function will exclude the specified category and change posts per page for the main blog posts index:

function wpse102566_pre_get_posts( $query ) {
    if ( is_home() && $query->is_main_query() ) {
        $query->set( 'category__not_in', array( '103' ) );
        $query->set( 'posts_per_page', 1 );
    }
}
add_action( 'pre_get_posts', 'wpse102566_pre_get_posts' );
share|improve this answer
    
i found that only non login user are facing problem . the users who login are able to see the posts –  user1001176 Oct 29 '13 at 23:07
2  
You have a deeper problem if Chip's code didn't work and you are seeing different results for logged in/not logged in users. Can you turn on debugging? –  Andrew Bartel Oct 29 '13 at 23:27
    
its like its going into a redirection loop when i open the posts page without login . and if i open that page after login . it works fine –  user1001176 Oct 29 '13 at 23:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.