It’s
'post_date'
not
'date'
so
$args = array( 'numberposts' => $items, 'post_type'=>'portfolio','orderby' => 'post_date','order'=>'DESC','category' => 5 );
$posts = get_posts($args);
foreach($posts as $post){
setup_postdata($post);
$return_html="......";
}
Should fix you up.
Related Posts:
- How do you add Read more … link to posts?
- Get current menu_order
- Set Default Listing “View” in Admin
- How to add category to: ‘wp-admin/post-new.php’?
- has_archive=false on the default post type
- Exclude drafts in all() view of edit.php
- How to publish a post with empty title and empty content?
- Change the Slug of Post Type post to baseurl/post/%postname%
- How do I use element instead of tags in WordPress post content having webP support?
- Prevent duplicate posts in wp_insert_post using custom fields
- How can I allow editors to leave comments on posts that have not yet been published?
- How to after saving or publishing a post redirect back to the original page
- How do I programmatically add an image to a post?
- Get user’s most published categories
- How to activate Markdown in a local installation of WordPress 4.3?
- setup_postdata doesn`t seem ot be working
- Single post as homepage?
- Pagination on single post page?
- Bulk update post slugs through database
- How To Remove Certain category Posts From the Blog Page
- Add icon/badge next to posttitle of specific category
- Ajax load more button in Recent posts widget
- Get posts of ONE taxonomy term of custom post type
- WordPress Custom Fields (Checkboxes with multiple values)
- How can I pass the ID of a post to a page template by clicking a url?
- How Can I Query a Specific Page From a MultiPage paginated Post
- Too many connections to server
- delete_post hook – deleting multiple items
- Change user role when post approve
- Whitelist Author of Private Post
- Custom Post Archive Page not working
- Adding buttons to Add New Post and Add New Page
- How do I phpunit test a post output process?
- Stop users posting into category while still seeing contents of the category
- Can wordpress post and sidebar remain visible after scroll?
- How to switch wordpress post status between publish and schedule in MySQL?
- Post Loop Missing Most Recent Post
- How to get posts from a current post’s month?
- Gather posts into a cart/lightbox and share with another user
- Wrong post title displayed from loop
- How do I extract just the post ID of the first item in whatever WP_Query returns?
- Disable WordPress Archive Conflict Check
- How to Use index.php file for “Blog” Page And this is Not a Home Page
- Sort Custom Post Type by Category ID then Post Name
- show posts under subcategory only when in that subcategory
- How include css class based on post ( in loop ) slug?
- WordPress Loop: How to display recent posts in multiple divs
- How to have one page show posts reverse-chronologically, but the others chronologically?
- When moving a WordPress installation to a new server, why do I have to update each post before content shows?
- wp_insert_post not working fine
- Post title is not showing
- Change Author Name to Sitename on Frontend
- Change default post style to columns
- Inserting Media to WordPress Posts
- Problem with trying to display subheader in posts
- Custom Post Type, post-formats associated to custom post type > 404 archives
- Add Text Domain To Post Navigation
- What’s a theme that properly handles previews of different types of posts?
- Using the loop to set locations for all posts on a single google map
- Change content off every sixth element
- WordPress, custom post type and posts query help!
- Custom post type and taxonomy page templates
- What would causes search to return incorrect results?
- WordPress – When visiting a `single post/ single.php` my category menu item link becomes active
- How to create a clickable latest posts list?
- Pagination not give another posts
- Get post slug and match with menu item slug to change css
- Tag for custom post type
- Can’t find webpage on All Pages or All Post menus
- Centre Blog Index (Posts Page) on Home.php
- How to display particular categorie’s post which associated to specific user?
- Display Specific Categories posts on the home page
- Code to display random ordered posts in Categories across pages [duplicate]
- Integrate video and iframe in a post type gallery
- Displaying a specific sub-category’s posts from wp_query
- Modify loop to include all post statuses not just ‘published’
- How to convert return type of ‘get_posts()’ same as ‘wp_get_recent_posts()’?
- Filter question list on substring of metavalue
- Embedding Facebook in blog post not working
- How to list all names and descriptions of a custom taxonomy
- Post List Widget with custom posts and editing the Read More Link
- WordPress Media URLs?
- Removing standard links in the posts page
- How to handle a post before publishing?
- How to get all post titles starting with numbers and symbols?
- How to inject a post within a loop
- How to display a certain template element only for posts published within certain time range?
- List direct children of page
- Unable to get posts with category on my page
- Multiple post back-to-back display only one gallery
- Auto selection of category based on subject line or TAG
- Single post pagination
- Wp_query WooCommerce products
- posts_per_page – Repeats only first posts ‘post__in’ array
- WP Rest API feature image breaking react component
- How can add custom commands in post-new.php in wordpress
- Filter/Sort Post Form On Taxonomy page
- sub posts to parent post
- How to move all images in a post to a single gallery for a bunch of posts?
- Display post by select it from a dropdown menu