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

1
  • let me get this right. You want to get the contents of the $dVC php variable in jquery. Is that correct?
    – Ijaas
    Commented Nov 3, 2011 at 2:23

1 Answer 1

2

Try outputting the JSON:

echo json_encode($dVC);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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