我想通過帖子ID顯示兩個帖子。但是我找不出用什麼代碼來調用帖子ID。誰能幫我嗎?如何使用帖子ID顯示特定帖子
///////////////////////////////
/////////// ///////////////////
<div class="food-featured-posts">
<div class="food-featured-posts-first">
<?php query_posts('p=185'); ?>
<div class="food-wrapper"><?php the_post_thumbnail(); ?>
<div class="popular-sticker">Popular</div>
</div>
<div class="food-featured-posts-info">
<h2><a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="post-excerpt"><?php echo get_the_excerpt(); ?></p>
<?php get_template_part('share-buttons'); ?>
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php comments_popup_link ('No Comments', '1 Comment', '% Comments', 'comment-count', 'none'); ?>
</div>
</div>
<div class="food-featured-posts-second">
<?php query_posts('p=173'); ?>
<div class="food-wrapper"><?php the_post_thumbnail(); ?>
<div class="popular-sticker">Popular</div>
</div>
<div class="food-featured-posts-info">
<h2><a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="post-excerpt"><?php echo get_the_excerpt(); ?></p>
<?php get_template_part('share-buttons'); ?>
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php comments_popup_link ('No Comments', '1 Comment', '% Comments', 'comment-count', 'none'); ?>
</div>
</div>
</div>
<h1 class="latest-in-food">Latest in food</h1>
更新代碼
<?php
$args = array(
'post_type' => 'post',
'meta_key' => '_thumbnail_id',
'p' => 185/173,
$query = new WP_Query($args);
<div class="food-featured-posts">
<?php while($query->have_posts()) : $query->the_post(); ?>
<div class="food-featured-posts-first">
<div class="food-wrapper"><?php the_post_thumbnail(); ?>
<div class="popular-sticker">Popular</div></div>
<div class="food-featured-posts-info">
<h2><a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="post-excerpt"><?php echo get_the_excerpt(); ?></p>
<?php get_template_part('share-buttons'); ?>
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php comments_popup_link ('No Comments', '1 Comment', '% Comments', 'comment-count', 'none'); ?>
</div></div>
<?php endwhile; ?>
<?php while($query->have_posts()) : $query->the_post(); ?>
<div class="food-featured-posts-second">
<div class="food-wrapper"><?php the_post_thumbnail(); ?>
<div class="popular-sticker">Popular</div></div>
<div class="food-featured-posts-info">
<h2><a class="post-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="post-excerpt"><?php echo get_the_excerpt(); ?></p>
<?php get_template_part('share-buttons'); ?>
<a class="moretext" href="<?php the_permalink(); ?>">Read more</a>
<?php comments_popup_link ('No Comments', '1 Comment', '% Comments', 'comment-count', 'none'); ?>
</div></div>
<?php endwhile; ?>
</div>
?>
<h1 class="latest-in-food">Latest in food</h1>
我將如何有效地添加此代碼INT o我的代碼在上面? – user6738171
http://wordpress.stackexchange.com/questions/89202/query-posts-only-with-featured-image檢查此鏈接的功能圖像/標題。 –
所以像我最初的答案更新的代碼?對不起,我不是最好的PHP,所以我不知道如何寫它。 – user6738171