Support » Fixing WordPress » Child Category Exclude

Viewing 4 replies - 1 through 4 (of 4 total)
  • $args = array(
        'child_of' => 5 (or whatever the id is)
    );
    
    $baz = get_categories( $args );
    
    foreach($baz as $foo)
    {
    	$exclude[] = $foo->term_id;
    }
    $query = new WP_Query( array( 'category__not_in' => $exclude ) );
    
    while($query->have_posts()) { $query->the_post(); the_content(); }

    Andrew,

    This looks awesome, but after I added the code, my website disappeared…I removed the code and it re-appeared, I’m thinking due to something in the code…any ideas?

    Thanks,
    Josh

    I copy/pasted it from my test environment after getting it to work. What did you replace the “5” with in line 2?

    I decided to go in another direction with this website…I’m doing the same thing, just doing it differently, making this question no longer valid.

    Thanks,
    Josh

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Child Category Exclude’ is closed to new replies.