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

I am trying to output portfolio items with a picture. This code doesn’t seem to be working. What am I doing wrong?

Are you trying to show the ‘featured image’? Or can you use it? If so, there is a simple way to do it: Add this line of code in your theme’s functions.php file, or be sure that it has this: add_theme_support( ‘post-thumbnails’ ); Add this line where you want to show the image: the_post_thumbnail(); Following … Read more

How to have the right design for a custom post type without accessing themes

Assuming that your custom post type is “songs”, I guess what you need is something like this: First, allow the theme to provide a design / template file for your custom post type, if WordPress can’t find one, fall back to your design, which you provided in your plugin folder. <?php // Template Logic: function … Read more