我使用以下代码来获取所有已注册的自定义帖子类型。但随之而来的是我希望按照我注册的顺序显示它们。
$custom_post_types = get_post_types(
array(
'_builtin' => false,
'public' => true
),
'objects'
);
ksort( $custom_post_types, SORT_ASC );
答案 0 :(得分:-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; ?>