我创建了一个名为rooms
. 我想得到所有rooms
贴子id为的贴子除外164
, 并使用以下代码显示:
<div class="room-container container room-grid">
<div class="heading-box">
<h2>rooms</h2>
</div>
<?php
$my_query = new WP_Query(\'post_type=rooms&posts_per_page=-1\');
$c = 1;
while( $my_query->have_posts() ) :
$my_query->the_post();
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb );
$content = get_the_content();
?>
<div class="room-box col-xs-6">
<div class="img-container">
<img src="<?php echo $img_url; ?>" alt="rooms">
<a href="#" class="btn btn-default">More Details</a>
</div>
<div class="details">
<div class="title">
<a href="#"><?php echo get_the_title(); ?></a>
</div>
<div class="desc">
<?php echo substr( $content, 0, 200 ); ?>...
</div>
</div>
</div>
<?php $c++; endwhile; ?>
</div>
最合适的回答,由SO网友:codieboie 整理而成
我得到了工作代码。房间不需要“房间”。谢谢朋友们。。
<?php
$my_query = new WP_Query( array(\'post_type\' => rooms, \'post__not_in\' => array(164)) );
while ($my_query->have_posts()) : $my_query->the_post();
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb);
$content = get_the_content();
?>