按所需顺序显示自定义帖子类型
问题描述:
我使用以下代码获取所有注册的自定义帖子类型。但是,随着我想按照我注册的顺序按照所需顺序显示它们。按所需顺序显示自定义帖子类型
$custom_post_types = get_post_types(
array(
'_builtin' => false,
'public' => true
),
'objects'
);
ksort($custom_post_types, SORT_ASC);
答
<?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; ?>
我不打算在显示自定义后类型职位,但本身挂号邮递类型的列表。 – Ninja