我试图获取帖子信息当我单击帖子上的按钮并使其与else函数中的信息相同时,我尝试添加一个查询,但作为回报,它使其回显所有帖子,而不是仅回显我单击的帖子
<?php $cb_bp_x_points = cp_displayPoints($bp->loggedin_user->id,1,$return,0,$format);
$cp_bp_points_for_content = 100;
if ($cb_bp_x_points >= $cp_bp_points_for_content) :
global $post;
if(isset($_GET[\'p\']) && $_GET[\'p\']==\'redeem\') { ?>
<div id="redeem">
<?php
$redeem_id = $prize_id;
$the_query = new WP_Query(\'post_type=prizes&p=\'.$redeem_id.\'&post_status=publish\');while ($the_query->have_posts()) : $the_query->the_post();
$post_redeem_id = get_post($redeem_id);
$redeem_title = $post_redeem_id->post_title;
echo $redeem_title;
endwhile;
}else{
?>
<? $the_query = new WP_Query(\'post_type=prizes&showposts=16&post_status=publish\');while ($the_query->have_posts()) : $the_query->the_post();?>
<div class="prize-1 prize">
<?php $prize_id = the_ID();?>
<div><?php the_title(); ?></div>
<div><?php the_content(); ?></div>
<div><?php echo get_post_meta($post->ID, \'redeem_points\', true); ?></div>
<span><a href="?p=redeem">Redeem</a></span>
</div>
<?php endwhile; ?>
<?php }?>
<?php else : ?>
<p>You must login</p>
<?php endif; ?>
更新了我的代码以更好地理解。。。
最合适的回答,由SO网友:Jeremy Love 整理而成
嗯,这很有效。。。
$the_query = new WP_Query("post_type=prizes&p=".$redeem_id."&post_status=publish&p={$_GET[\'post_id\']}");while ($the_query->have_posts()) : $the_query->the_post();
<span><a href="?p=redeem&post_id=<?php echo $post->ID; ?>">Redeem</a></span>