0

我在 wordpress 中创建自定义帖子类型以创建投资组合,然后在主页中我希望此脚本显示我的最后四个客户

                    <!-- INIZIO LOOP PER L'ESTRAZIONE E RICHIAMO DATI PORTFOLIO-->
                <?php

                    //Array di configurazione Loop
                    $args = array(
                        'post_type' => 'portfolio',
                        'post_per_page' => 4
                    );
                    $nuovo_loop = new WP_Query( $args );
                        if( $nuovo_loop->have_posts() ) :
                        while( $nuovo_loop->have_posts() ) : $nuovo_loop->the_post();
                ?>

                <!-- Cosa fare dentro il loop -->
                <div class="grid_3 portElements">

                    <div class="full_overlay">
                        <div class="content">
                            <span class="portfolioimage">
                                <p><?php the_title(); ?></p>
                                <a href="<?php the_permalink(); ?>" target="_self">
                                    <span class="DWSdetails">dettagli</span>
                                </a>
                                <a href="<?php
  $myExcerpt = get_the_excerpt();
  $tags = array("<p>", "</p>");
  $myExcerpt = str_replace($tags, "", $myExcerpt);
  echo $myExcerpt;
  ?>" id="outLink" target="_blank">
                                    <span class="view">visita </span>
                                </a>

                            </span>
                        </div>
                        <div class="portImage" >
                             <?php if ( has_post_thumbnail() ) {
                                        the_post_thumbnail('thumbImage');
                                    }else{
                                        echo '<img src="http://www.dywes.com/wp-content/themes/dywes/images/workinprogress.png" />';
                                    }
                            ?>
                        </div>

                    </div>
                </div>
                <?php
                    endwhile;
                    else:
                ?>  
                <!-- Cosa fare se il loop non trova niente -->
                <?php 
                    endif;
                    wp_reset_postdata();
                ?>


            </div>
                <!--FINE LOOP PORTFOLIO-->

但是当我重新加载页面时,我看到了我所有的客户......我怎样才能看到其中的 4 个?

4

2 回答 2

0
$args = array(
                    'post_type' => 'portfolio',
                    'posts_per_page' => 4,
                    'order' => 'DESC',
                    'orderby' => 'post_date'
                );

这应该显示最后 4 个。您可以在Codex中找到更多详细信息

于 2013-11-08T12:58:13.897 回答
0

你的论点 $args 是错误的,它是 posts_per_page ,而不是 post_per_page

$args = array(
                    'post_type' => 'portfolio',
                    'posts_per_page ' => 4
                ); 
于 2013-11-08T13:02:06.727 回答