最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - CPT loop doesn't seem to account for post date?

programmeradmin4浏览0评论

I have some custom post types called "products", all with different published dates. Below is my loop that grabs these posts:

 $args = array(  
    'post_type' => 'product',
    'post_status' => 'publish',
    'posts_per_page' => $numposts, 
    'orderby' => 'date',
    'order' => 'DESC',
    'product-category' => $cat,
    'paged' => $paged,
    'author' => $author,
);

$loop = new WP_Query( $args ); 
if (!$loop->have_posts()){
    return 'No products available.';
}

I have my orderby set to date desc, but it's not taking effect on the frontend (they're just randomly ordered). What's also odd is that in the backend, if I look at my custom posts and sort by the "date" column, they don't sort there either. It's like it can't read the published date even though the date is showing on each post. Thoughts?

发布评论

评论列表(0)

  1. 暂无评论