Unable to get post content from custom post type loop

As other answers mentioned, you aren’t in The Loop so get_the_*() functions aren’t going to work properly. Since you’re looping over $query->get_posts() you can just use the WP_Post object. Something like this will work. foreach($query->get_posts() as $testimonial): $meta = get_post_meta($testimonial->ID); foreach($meta as &$m){ if(is_array($m)){ $m = $m[0]; } } <div class=”content”><?= do_shortcode($testimonial->post_content); ?></div> <div class=”author”>- … Read more

wordpress post loop in javascript

<?php ob_start(); query_posts(array(‘post_type’ => ‘topnews’)); while (have_posts()) : the_post(); ?> { // the_title() can use a false to return the value for use with strip_tags (apparently) ‘title’ : ‘<?php echo stripslashes(the_title(false)); ?>’, // Where is this $desc coming from? ‘button_list’ : [ { ‘title’:’Demo’, ‘url’ : ‘http://bonchen.net/’ }, { ‘title’:’Download’, ‘url’:’http://porfolio.bonchen.net/’} ], ‘tags’ : [‘Portrait’] … Read more