I wonder if a single typo is messing things up for you? Please try this:
$args = array(
'posts_per_page' => '-1',
'orderby' => 'ID',
'order' => 'DESC',
'category_name' => 'documents'
);
$surveys = get_posts($args);
where I replaced category-name
with category_name
.
I know there is ways to exclude categories by ID but I need to use the
category slug as my dev and live databases do not match.
There exists for example the function get_category_by_slug()
that you can use if you need to get the term_id
from the slug
:
if( FALSE !== ( $obj = get_category_by_slug('some-category-slug') ) )
{
$id = $obj->term_id;
}