• Resolved mo2007

    (@mo2007)


    am having a a problem…..I have 3 sections of my website that use the query_posts:

    <?php $posts = query_posts( "cat=8&showposts=1"); ?> <?php if( $posts ) : ?>
    
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>

    what I needed appears on the front page. I also use it for my index.php to exclude categories that I don’t want to show, the problem is, how do I create my single.php

    I tried copying everything in index.php and pasting it into single.php, but nothing happens. I have put <?php wp_reset_query(); ?> at the end of all the 3 sections….nothing ??

    any helps would be appreciated..thanx in advance

Viewing 1 replies (of 1 total)
  • Thread Starter mo2007

    (@mo2007)

    ok found the answer….basically I used the WP_Query where I can set my own query without effecting other pages. I done this for the index.php using this code:

    <?php
        $selectedPosts = new WP_Query();
        $selectedPosts->query('cat=-1&showposts=10');
    ?>
    
    <?php while ($selectedPosts->have_posts()) : $selectedPosts->the_post(); ?>

    I define a variable and set what I want to show and exclude. I used this for all 3 sections of the website that show certain posts from certain categories.

    I then use the normal Loop in the single.php and IT WORKED!!! Thank GOD!!

Viewing 1 replies (of 1 total)
  • The topic ‘query_posts in index.php is working, but single.php is NOT!!! help’ is closed to new replies.