嗨,我在用这些9 wp\\U查询输入index.php我想知道有没有其他方法可以做同样的事情,但不需要使用大量的查询?
<?php $bigindex = new WP_Query(\'posts_per_page=1&post_status=publish\'); ?>
<?php if (have_posts()) : while ($bigindex->have_posts()) : $bigindex->the_post(); ?>
<?php if( $post->ID == $do_not_duplicate ) continue; ?>
<header class="article-header header-vertical-position-mid <?php the_field(\'posttype\'); ?> latest-article" style="background-image: url(<?php the_field(\'320px\'); ?>);">
<div class="container">
<div class="article-header-elements">
<h1 class="article-title">
<a href="<?php the_permalink();?>" title="<?php the_title(); ?>">
<span class="article-highlight">
<?php the_title(); ?>
</span>
<small class="article-subtitle">
<span class="article-highlight">
<?php the_field(\'shorttext\'); ?>
</span>
</small>
</a>
</h1>
<p class="article-meta">
<span class="article-highlight">
<i class="fa fa-<?php the_field(\'randico\'); ?>"></i>
Last Post •
<time datetime="<?php the_time(\'F j, Y\'); ?> "><?php the_time(\'F j, Y\'); ?> </time>
</span>
</p>
</div>
</div>
</header>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
<div class="company-news">
<a href="#" title="news">
<h2>
News | <time datetime="2017-01-03T00:00:00Z">2017 . 01 . 03</time>
<small>Something goes here</small>
</h2>
</a>
</div>
<div class="additional-posts">
<div class="article-thumbnail-container">
<div class="article-thumbnail-row">
<?php $meindex = new WP_Query(\'posts_per_page=4&post_status=publish&offset=1\'); ?>
<?php if (have_posts()) : while ($meindex->have_posts()) : $meindex->the_post(); ?>
<?php if( $post->ID == $do_not_duplicate ) continue; ?>
<div class="article-thumbnail <?php the_field(\'posttype\'); ?> article-thumbnail-bottom-border" style="background-image: url(<?php the_field(\'320px\'); ?>);">
<a href="<?php the_permalink();?>" title="<?php the_title(); ?>">
<div>
<span class="article-thumbnail-title">
<i class="fa fa-<?php the_field(\'randico\'); ?>"></i><?php the_title(); ?>
</span>
</div>
</a>
</div>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
</div>
</div>
<div class="container">
<div class="more-articles">
<h2>
<span class="highlight">Recent Posts...</span>
</h2>
<ol class="article-index-list">
<?php $meindex = new WP_Query(\'posts_per_page=20&post_status=publish&offset=5\'); ?>
<?php if (have_posts()) : while ($meindex->have_posts()) : $meindex->the_post(); ?>
<?php if( $post->ID == $do_not_duplicate ) continue; ?>
<li class="article-index-item <?php the_field(\'posttype\'); ?>">
<a href="<?php the_permalink();?>" title="<?php the_title(); ?>">
<div class="article-index-item-header" style="background-image: url(<?php the_field(\'320px\'); ?>);"></div>
<div class="article-index-item-text">
<div class="article-index-item-category">
<span>
<?php the_field(\'caticoname\'); ?>
</span>
</div>
<h3>
<?php the_title(); ?>
<small><?php the_field(\'shorttext\'); ?></small>
</h3>
</div>
</a>
</li>
<?php endwhile; endif; ?>
还有3个这样的查询
<li class="dropdown interviews nav-item">
<a aria-expanded="false" aria-haspopup="true" class="nav-link" data-target="#" data-toggle="dropdown" href="/interviews/" id="dInterviews">
<i class="fa fa-users"></i>Interviews
</a>
<div aria-labelledby="dInterviews" class="dropdown-menu">
<div class="article-thumbnail-container">
<div class="article-thumbnail-row">
<?php $jpindex = new WP_Query(\'posts_per_page=3&post_status=publish&cat=5\'); ?>
<?php if (have_posts()) : while ($jpindex->have_posts()) : $jpindex->the_post(); ?>
<?php if( $post->ID == $do_not_duplicate ) continue; ?>
<div class="article-thumbnail interviews" style="background-image: url(<?php the_field(\'320px\'); ?>)">
<a href="<?php the_permalink();?>" title="<?php the_title(); ?>">
<div>
<span class="article-thumbnail-title"><?php the_title(); ?></span>
</div>
</a>
</div>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
<div class="article-thumbnail article-thumbnail-archive interviews">
<a href="/interviews/" title="Interviews archive">
<div>
<i class="fa fa-users"></i>
<br>
More..
</div>
</a>
</div>
</div>
</div>
</div>
</li>