2017-06-05 27 views
0

我使用以下代碼獲取所有註冊的自定義帖子類型。但是,隨着我想按照我註冊的順序按照所需順序顯示它們。按所需順序顯示自定義帖子類型

$custom_post_types = get_post_types( 
    array(
     '_builtin' => false, 
     'public' => true 
     ), 
    'objects' 
    ); 

ksort($custom_post_types, SORT_ASC); 

回答

-1
<?php 
$args = array('post_type' => 'custom_type_name', 'posts_per_page' => 50 'orderby' => 'date', 
     'order' => 'ASC'); 
$loop = new WP_Query($args); 
while ($loop->have_posts()) : $loop->the_post(); 
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($loop->ID), 'full'); 
$url = $thumb['0']; 
?> 
<a href="<?php echo get_the_permalink(); ?>">  
<img src="<?php echo $url ?>" alt="<?php the_title(); ?>" class="img-responsive" width="100%"/></a> 
<h3><a href="<?php echo get_the_permalink(); ?>"> <?php the_title(); ?></a></h3> 
<p><a href="<?php echo get_the_permalink(); ?>" class="hvr-bounce-to-top redbtn"> Read More</a></p> 
<?php endwhile; ?> 
+0

我不打算在顯示自定義後類型職位,但本身掛號郵遞類型的列表。 – Ninja

相關問題