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;
}
Related Posts:
- exclude category from get_posts?
- Get id of category from drop down menu
- Show post only if match all categories
- Show recent posts from one category on a non-WP site
- get_posts and multiple categories
- Trying to only display 1 category using get_posts
- Get link which associated with a specific category and tag
- Get posts from 2 different categories
- Get posts from specific taxonomy term
- List all posts in a category with query_post() function
- Hooking to walker_nav_menu_start_el to insert list of subpages
- get_posts ignoring ‘category’ and displaying all posts
- How to pull a list of posts in a category while exluding posts in subcategories of the category
- How to Link to Most Recent Custom Post of Same Term
- get_posts() from parent category only using a shortcode
- Exclude categories from homepage not longer working
- Showing posts from 2 categories only on category.php
- get all categories’ latest post in one query
- Load the last post of a category
- get_the_category return empty inside loop
- Get posts base on category ratio of more then two categories
- Media Library Category Exclude Tree
- not empty categories don’t show in menu [closed]
- how to call the category of the post
- How to create a custom loop ordered by Categories on a Page Template?
- How to change category id on get_posts array
- get posts from 2 categories. (2 posts)
- how to ask if in two categorys inside if
- How to create a custom sort for WordPress categories
- How to add the category ID to admin page
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Category Archive
- Filter categories using tags
- Sticky posts on home page, search, tag and archives without plugin
- Show Post from parent category (custom taxonomy) ONLY!
- Filtering Children of the “uncategorized” Category out of the Loop?
- How do I get the total number of categories in a list of search results?
- Update wordpress post terms programatically
- Display products for a category, sorted by post_excerpt
- Creating archive pages for children categories
- “NOT ONLY IN” taxonomy query operator?
- How do you bulk remove a category from posts?
- How to remove the “+Add Category” button from the Category metabox?
- Display the featured image from the last post
- conditional for sub category on archive page
- Arrange posts by date in front page
- “Categories” on my front page [closed]
- Warning: sizeof (): Parameter must be an array or an object that implements Countable, On products pages
- How to loop only categories without posts (+ show category featured image with acf) [closed]
- How can I create a Category Index page that lists all categories?
- create a page which displays a list of categories title+ short description?
- Changing permalink from /postname/ to category/postname/
- Scheduling update post daily
- Retrieving category’s color with get_term_meta
- How to exclude children categories of parent category
- Assign category from custom field on post creation and update
- Sticky posts not working when a specific category is set
- Custom category URL rewriting
- Get Number of total Parent Categories for Custom Taxonomy
- How to change how many list item show in category generated by file edit-tags.php
- How to display numbered pages in a category
- How can I add an “ALL CATEGORIES” entry in wp_dropdown_categories?
- How do I display something on a particular category page?
- Using a rich text editor for category description?
- How to put page numbers with the next/previous on a post/category list?
- Overriding default calendar to show posts from a category
- Categories will only display links to posts
- Adding category dropdown list to theme options page
- How to get posts by category at /%category%/ url?
- Echo text using is_tag
- Cannon see subcategory in permalink
- Custom row actions on a specific category
- How to not display a category post on blog page?
- Are term_taxonomy_id and term_id the same? [duplicate]
- Display all sub category but one
- Filter Category Loop Dynamically
- SQL query to get posts from multiple categories but not in a category
- Can each user have only access to a private area (his own categories and posts)?
- WP Category Meta plugin fix? [closed]
- WP SQL Categories Export and Import
- How to display WooCommerce category image in my category page banner as a background?
- Why are my newly added categories not showing up when creating a post?
- WordPress Default Category and Custom Taxonomy Selected Attribute not Working After Searched in wp_dropdown_categories Array
- Order wp_dropdown_categories by ASC or DESC
- Add filter for specific category only
- How to exclude a category returned by get_categories from function.php?
- How to get get_categories()’s ‘hide_empty’ argument to work with global year var in the archive template?
- Getting a sub category based on a category name
- How to display only sticky posts on category pages?
- I have many different products on my website how can I get them to display under specific categories?
- Help with SQL query, how to add taxonomie terms with value stored in options?
- /blog/ permalink prefix causes category pages to 404
- Display Referring Category on single post?
- Conditional statements based on custom meta value in category archives
- Placement of categories
- Display deepest post category, when post have multiple categories
- Paginate WordPress Category Pages
- Get a list of post titles and links from yootheme master theme
- Excluding cateory not working on my site. how to solve this? [closed]
- Get all first images of posts in same category
- Replace category titles inside RSS feed