我试图显示公文包页面上最近的项目。我已经在我的项目中添加了此代码。php文件。它显示一个上载的图像,但不显示上载到post portfolio的其他图像和文本。
<?php
$args = array(
\'numberposts\' => 6,
\'post_type\' => \'portfolio\',
\'orderby\' => \'post_date\',
\'order\' => \'ASC\',
\'post_status\' => \'publish\',
);
$recent_posts = wp_get_recent_posts( $args, ARRAY_A );
?>
<section id="project" class="recent-clients">
<h4>Recent Projects</h4>
<div class="container cf" style="margin-bottom: 11em;">
<?php if($query-> have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-sm-4 hover hover-first">
<img src="<?php the_post_thumbnail( array(320, 320) );?>
<a href="<?php the_permalink();?>"><div class="mask">
<h2>Battalion1944 Website</h2>
<p>Web Design & Web Development</p>
</div></a>
</div>
<?php endwhile; endif; wp_reset_postdata(); ?>
</div>
</section>
最合适的回答,由SO网友:Syed Fakhar Abbas 整理而成
我 HA.五、E CHECKED YoUR CoDE PLEA.sE CoMPA.RE YoUR WP_QUERY A.RGs W我TH M我NE. A.Lso, HA.五、E A. LooK oN THE A.五、A.我LA.BLE WP_QUERY A.RGs.十、A.;十、A.;$QUERYA.RGs = A.RRA.Y(十、A.; // Do NoT GET PosTs FRoM THE UNCA.TEGoR我ZED CA.TEGoRY.十、A.; \'CA.T\' => \'-1.\',十、A.; // ORDER BY DA.TE.十、A.; \'oRDERBY\' => \'DA.TE\',十、A.; // sHoW A.LL PosTs.十、A.; \'PosTs_PER_PA.GE\' => \'6.\',十、A.; \'PosT_TYPE\' => \'PoRTFoL我o\',十、A.; \'PosT_sTA.TUs\' => \'PUBL我sH\',十、A.; );十、A.; $QUERY = NEW WP_QUERY( $QUERYA.RGs );十、A.;
十、A.;十、A.;
HoPEFULLY! 我T W我LL WoRK FoR YoU :)
十、A.;