自定义帖子类型循环


Custom post type loop

我需要一些指导。

我正在工作的自定义post类型循环,但我卡住了如何将这个静态html转换为php循环

<?php 
    $loop = new WP_Query(array('post_type' => 'project', 'posts_per_page' => -1));
    $count =0;
?>
<!--Text Sliders-->
<div class="ps-contentwrapper">
    <?php if ( $loop ) : 
        while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
$terms = get_the_terms( $post->ID, 'tagproject' );
if ( $terms && ! is_wp_error( $terms ) ) : 
    $links = array();
    foreach ( $terms as $term ) 
    {
        $links[] = $term->name;
    }
    $links = str_replace(' ', '-', $links); 
    $tax = join( " ", $links );     
else :  
    $tax = '';  
endif;
?>
    <?php $infos = get_post_custom_values('_url'); ?>
    <div class="ps-content">
        <h2><?php the_title(); ?></h2>
        <p><?php echo get_the_excerpt(); ?></p>
    </div><!--end of ps-content-->

</div><!-- /ps-contentwrapper -->
<!--Image Sliders-->
<div class="ps-slidewrapper">
    <div class="ps-slides">
        <?php
            $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
        ?>
        <div style="background-image: url(<?php echo $url; ?>);"></div>
    </div>
        <?php endwhile; else: ?>
    <?php endif; ?>
    <nav>
        <a href="#" class="ps-prev" style="background-image: url(images/home/1.jpg);"></a>
        <a href="#" class="ps-next" style="background-image: url(images/home/2.jpg);"></a>
    </nav>  

这是我试图转换的教程。演示。

我想弄清楚的是如何动态地排列所有东西。如果有人能给我指出正确的方向,我会很感激。

我的版本和我粘贴在上面的当前代码。

编辑:这是我的代码现在经过一点研究。现在我想弄清楚我如何能匹配的特色图像到适当的帖子,因为它在这个脚本中循环。响应url的div标签需要按照循环的次数循环,并适当地循环。
<div class="ps-slides">
                    <?php
                        $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
                    ?>
                    <div style="background-image: url(<?php echo $url; ?>);"></div>
                </div><!--end of ps-slides-->

完整代码如下:

<div class="ps-contentwrapper">
                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <div class="ps-content">
                        <h2><?php the_title(); ?></h2>                      
                        <p><?php echo get_the_excerpt(); ?></p>             
                    </div>
                        <?php endwhile; ?>  
                    <?php endif; ?>             
            </div><!--end of contentwrapper-->
            <!--Image Sliders-->
            <div class="ps-slidewrapper">
                <div class="ps-slides">
                    <?php
                        $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
                    ?>
                    <div style="background-image: url(<?php echo $url; ?>);"></div>
                </div><!--end of ps-slides-->
                <nav>
                     <?php
                        $prev_post = get_previous_post(); 
                        $id = $prev_post->ID ;
                        $permalink = get_permalink( $id );
                        $prev_url = wp_get_attachment_url( get_post_thumbnail_id($id) );
                        ?>
                            <a href="#" class="ps-prev" style="background-image: url(<?php echo $prev_url; ?>);"></a>
                        <?php 
                            $next_post = get_next_post();
                            $nid = $next_post->ID ;
                            $permalink = get_permalink($nid);
                            $next_url = wp_get_attachment_url( get_post_thumbnail_id($nid) );
                        ?>
                        <a href="#" class="ps-next" style="background-image: url(<?php echo $next_url; ?>);"></a>
                </nav>
            </div>

使用代码为您的上一个下一个帖子图像url:

<?php
    $prev_post = get_previous_post(); 
    $id = $prev_post->ID ;
    $permalink = get_permalink( $id );
    $prev_url = wp_get_attachment_url( get_post_thumbnail_id($id) );
?>
<a href="#" class="ps-prev" style="background-image: url(<?php echo $prev_url; ?>);"></a>
<?php 
    $next_post = get_next_post();
    $nid = $next_post->ID ;
    $permalink = get_permalink($nid);
    $next_url = wp_get_attachment_url( get_post_thumbnail_id($nid) );
?>
<a href="#" class="ps-next" style="background-image: url(<?php echo $next_url; ?>);"></a>