Did you try the example given in the codex?
<?php
global $post;
$args = array( 'numberposts' => $number, 'category' => 6, 'order' => 'ASC', 'orderby' => 'post_date' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li><a href="https://wordpress.stackexchange.com/questions/20091/<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
This a modified version that should suit your needs. Are you also certain that this category exists?
Edit:
<?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query('showposts=" . $numberposts . "&cat=6&orderby=date&order=ASC'); ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<!-- your content -->
<?php endwhile; ?>
<?php $wp_query = null; $wp_query = $temp; ?>
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
- 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 parent category when getting category posts by slug
- 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
- is_category() function
- Create terms when registering taxonomy?
- How do I edit pre_get_post for the category the user is currently in?
- Remove “Category Archives: title” at the top of a category page [duplicate]
- Category Alphabet List Broken
- Display only one result from “get_the_category_list”
- Display empty taxonomy terms with get_terms()
- Show list of categories even if they have no posts
- Assign an icon to a category post
- How can I show the subcategories content on the parent category page?
- Custom Category/Subcategory structure
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Format Brand value in Category view [closed]
- Remove ‘rel’ attributes from the_category() output
- Default category link for a custom category is a broken link
- Get multidimensional array that reflects category hierarchy
- 3 Columns, 3 Categories, One Archive, and Pagination
- Possible to make a subdirectory that loops through a single category?
- Archives for each category on WP Multisite
- Update post title with category name after editing a category
- Automatically set default password to all posts in a specific category
- Checkboxes in the category list?
- Automatically exclude categories from metabox based on title
- How to display post categories within the Latest Posts block?
- How do I output all category with custom field?
- Add /category/ to an author archive page
- Remove subcategory and category with some rules from permalink
- How can I edit the ‘Most Used’ tab in the categories meta-box to show another custom taxonomy?
- Does “show_option_all” in wp_list_categories do anything?
- redirecting from a general category page to another specific one
- Categories are not listing their respective products
- Pagination on category.php and tag.php not working
- How to do paging in the loop?
- query_posts not reading correct categories
- how to nest specific category thumbnails inside different containers
- Eliminate word from $term->name
- Is there any way to check which wordpress categories was created by which user?
- Adding a block with query in homepage
- multiple values in an array for category__and does not work with WP_Query
- Category view with contents of [gallery]s shown
- How can I include custom category and tag base in template files?
- query_post problem
- Add properties to term object
- Display all Categories
- custom wp_list_categories in single.php
- How to target all woocommerce categories that don’t have any subcategories in them?
- Is this process OK to replace URL structure?
- How can i echo next and previous custom category from a Taxonomy
- No hierarchy in wp_list_categories with child of and depth
- How to check a category checkbox using JavaScript
- Need help to structure our a complex hierarchy
- global categories – Share specific categories in wordpress multisite
- create post with main category and other categories from admin panel
- How Can Hide Define Category in Post Contents?
- How to auto update post title and slug with category name when post status is updated
- get_posts – require all categories
- 404 error when i try to search by category or by tag
- Choosing different templates for categories
- How do you add Author and date Published on Category Pages?
- hierarchical taxonomy in permalinks? using same slug
- WordPress Numeric Pagination with Query String [duplicate]
- Changing Permalinks for Category Pages Only
- Twenty Eleven Theme [duplicate]
- display certain category on custom template page
- Get post by Category in custom template
- Ajax call activate after submit in edit-tags.php page
- Assign a category by user and customize the edit-tags.php?taxonomy=category page
- comments_number fails to print
- wordpress show category link instead of post link [closed]
- Sorting Woocommerce products by category and attributes
- How to show child category name & post from it’s parent [closed]
- Open everything in new tab