I am using this code, but it is not going after the first request:
<?php $thePostIdArray = array( '2', '4', '5'); ?>
<?php $limit = 4; ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); $counter++; ?>
<?php if ( $counter < $limit+1): ?>
<div class="post" id="post-<?php the_ID(); ?>">
<?php $post_id = $thePostIdArray[$counter-1]; ?>
<?php $queried_post = get_post($post_id); ?>
<?php $title =$queried_post->p开发者_运维技巧ost_title; ?>
<?php $content = $queried_post->post_content; ?>
<h2><span><?php echo $title ?></span></h2>
<?php echo $content; ?> </div>
<?php endif; ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<?php endif; ?>
It is only out putting the first page(2) of the request even though the footer and the sidebar are been queried. I eliminate the sidebar and the footer, but no change so the problem is not from them. Any help here will be appreciated. By the way I am using the lasted wordpress
You don't need The Loop since you know the IDs of the posts (or pages).
<?php
$thePostIdArray = array( '2', '4', '5');
foreach ($thePostIdArray as $thePostId):
$thePost = get_post($thePostId);
<?php if (!empty ($thePost)): ?>
<div class="post" id="post-<?php echo $thePostId; ?>">
<?php $title =$thePost->post_title; ?>
<?php $content = $thePost->post_content; ?>
<h2><span><?php echo title ?></span></h2>
<?php echo $content; ?> </div>
<?php endif;
endforeach; ?>
精彩评论