• I opened up loop.php because I want to exclude some categories from the blog. I have a static homepage and I created a blank blog page with a blog category. So all posts made that are for the blog will be posted under the blog category. In loop.php I added this code to the top of the loop
    `
    <?php $options = get_option('option_tree');
    //looping through my key to get the values
    foreach($options['exclude'] as $cat) {

    //concatenating my values into one string
    $string .= '-' .$cat.",";
    }

    //trimming the trailing comma from the string
    $string = substr($string, 0, -1); // Delete the last character

    query_posts( 'cat=' . $string . '&paged=' . $paged);
    ?>

    <?php while ( have_posts() ) : the_post(); ?>//the loop continues as normal

    the code does work as all the categories did disapear from the blog page. My only issue is that the first default wordpress code that is in the uncategorized section got duplicated for some reason and shows up twice. Now yes, I could just easily hide this category, but I would like my code to be 100% correct without any cheating. Anyone got any idea what I am doing wrong?

The topic ‘help with modifying loop’ is closed to new replies.