Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Need some ninja guru help on a function to exclude cats from loop


MrMaz
Participant

@mrmaz

query_posts() is expecting an array to passed to it for the arg ‘category__not_in’. It looks like you are passing it a string of ids separated by commas. get_exclude_categories_loop() should be returning an array.

query_posts(array('category__not_in' => array(2,6)));

See multiple category handling here:

https://codex.wordpress.org/Template_Tags/query_posts

This is not valid PHP:

<?php
query_posts(array('category__not_in' => array(get_exclude_categories_loop))); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

This is:

<?php
query_posts( array( 'category__not_in' => get_exclude_categories_loop() ) ); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Skip to toolbar