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.
<?php
$dVC=array();
query_posts('meta_key=featuredt&posts_per_page=5');
if (have_posts()) :
while (have_posts()) : the_post();
$dVC []= $post->post_content;?>
<div id="featuredt-<?php echo $wp_query->current_post;?>">
<?php echo get_post_meta($post->ID, 'featuredt', TRUE);?></div>
<?php endwhile;
endif;
json_encode($dVC);
?>

This is my loop at the moment.

I need the json encoded variable to look like ["0":content, "1":content] so I can use jQuery.parseJSON() on it. I don't mind people telling me about jQuery.getJSON() but I have less of an idea how to use it then parseJSON. Please provide detailed examples when explaining, I really would appreciate any help I could get though.

share|improve this question
    
let me get this right. You want to get the contents of the $dVC php variable in jquery. Is that correct? –  Ijaas Nov 3 '11 at 2:23
add comment

1 Answer

Try outputting the JSON:

echo json_encode($dVC);
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.