Ich versuche, zwei spezifische Beiträge mit der Post-ID zu zeigen. Ich kann jedoch nicht herausfinden, welcher Code verwendet wird, um die Post-IDs aufzurufen. Kann mir jemand helfen?Wie man bestimmte Post mit Post-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>
UPDATE CODE
<?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>
Wie würde ich diesen Code int effektiv hinzufügen o mein Code oben? – user6738171
http://wordpress.stackexchange.com/questions/89202/query-posts-only-with-featured-image Überprüfen Sie diesen Link für Feature-Bild/Titel. –
Also wie der aktualisierte Code in meiner ursprünglichen Antwort? Sorry, ich bin noch nicht der Beste bei PHP, also weiß ich nicht, wie ich es schreiben soll. – user6738171