我已經創建了一個自定義帖子類型,以在我的投資組合網站上從我的博客手工製作摘錄。我有一個內容窗口,一個鏈接和一個帖子類型的精選圖片,我稱之爲blog
。wordpress自定義帖子類型不能改變顯示順序
問題是,無論我嘗試什麼,帖子都會顯示爲最新的,但我想先顯示最新的帖子。這裏的query_posts()
電話:
<?php query_posts('post_type=blog&order=ASC'); ?>
但我也嘗試更復雜的查詢,如:
<?php query_posts(array('post_type' => 'blog', 'orderby'=>'date','order'=>'ASC')); ?>
我的完整模板文件看起來像: ` 「>
<div class="sliderContent">
<!--first loop-->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(__('Read More »', THEMENAME)); ?>
<?php endwhile; else: ?>
<p><?php _e('Nothing found.', THEMENAME); ?></p>
<?php endif; ?>
<!--second loop, displays custom post type-->
<?php query_posts(array('post_type' => 'blog', 'orderby'=>'date','order'=>'ASC')); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="contenttile">
<p><a href="<?php echo get_post_meta($post->ID, 'Permalink', true); ?>"><?php the_post_thumbnail('medium'); ?></a></p>
<h2><?php the_title(); ?></h2>
<?php the_content(__('Read More »', THEMENAME)); ?>
</div>
<?php endwhile; else: ?>
<p><?php _e('Nothing found.', THEMENAME); ?></p>
<?php endif; ?>
</div>
</div>
<!-- content end -->
<?php } ?>
`
所以我顯示來自該模板應用頁面的內容,那麼我顯示我的自定義後的類型。
感謝您的幫助,我很難過!
正如另一位回答者指出的,在這裏我選擇了'ASC'作爲排序順序,但是我可以將其更改爲'DESC'並且它沒有區別。事實上,它有點像'query_posts()'忽略查詢的每一部分,但'post_type'?那可能嗎? – catdotgif