Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
Two things get_the_content() and get_the_title() do just that, they get the data, but do not echo it. Use the_title() and the_content() to echo the data. Just curious as to why you are using timthumb when WP 2.9+ has built in thumbnail support? See: codex.wordpress.org/Function_Reference/add_image_size –  Brian Fegter Oct 12 '11 at 2:33
    
because im old school lol, on a serious note im just putting my code together and getting different things from my other codes before I complete it, but i did have the_title and the_content and the results came back blank after that so I figured I would try those 2 and its still blank, any other suggestions? –  Jeremy Love Oct 12 '11 at 4:01
    
get_the_content and get_the_title are not in the loop and therefore won't work correctly because the postdata is not setup correctly. –  Brian Fegter Oct 12 '11 at 4:08
    
even when in the loop it gets all the post instead of just the one i selected –  Jeremy Love Oct 12 '11 at 4:26
    
$the_query = new WP_Query('post_type=prizes&post_status=publish'); will return all posts matching the type and the status, that's why you're getting a lot of them. Try get_post() supplying it the ID of the post you want to get the information for instead of a query. Also don't $_GET['post'] since post is a reserved variable and if it's present in the query then you're probably on a single page. On the other hand, I've not understood the question to its fullest extent, just chiming in. –  soulseekah Oct 17 '11 at 12:40
show 2 more comments

2 Answers

up vote 0 down vote accepted

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>
share|improve this answer
add comment

Don’t use a reserved variable as a GET (or POST) parameter, this won’t work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.