get selected post using $_GET

im trying to get a post info when I click a button on the post and make it echo out the the same info it has in the else function, I tried adding in a query but in return it makes it echo back all the post instead of just the one im clicking on

        <?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; ?>

updated my code for better understanding…

Related posts

Leave a Reply

2 comments

  1. Well this worked…

    $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>