1
請幫助我這個煩人的問題,因爲我在WordPress的初中,我有一個不同的滑塊在我的項目,我做了一個自定義帖子類型,使附件帖子在使每一個帖子作爲滑塊..問題是如何循環內部CPT檢索每一個職位,當我想要顯示在前端我試了很多,並在網上搜索有關它,但唯一的代碼,我發現,我用它使每一個職位覆蓋第一篇文章..這是我的代碼如何在wordpress中自定義帖子類型中的單個附件帖子中循環?
<?php
$query = new WP_Query(array(
'post_type' => 'owlgalleryslider',
'posts_per_page'=> 3,
'fields' => 'ids'
));
$image_query = new WP_Query(array(
'post_type' => 'attachment',
'post_status' => 'puplish',
'post_mime_type' => 'image',
'posts_per_page' => 3,
'post_parent' => $query->id,
'order' => 'DESC'
));
?>
<?php if(have_posts()) : ?>
<?php while ($image_query->have_posts()) : $image_query->the_post(); ?>
<div class="item owl-slide"> <img src="<?php echo wp_get_attachment_url(get_the_ID()); ?>" /> </div>
<?php endwhile; wp_reset_query();?>
<? endif;?>
我買了我想要的只是或CPT中的三個附件帖子,並通過它們循環.. –