I've created a plugin that sets up a custom post type ('Programmes'), taxonomy and a short code to display the custom posts. I'm trying to display a custom post meta field (Broadcast Date) via the shortcode. These are the methods I've tried so far:
This is the method I'd have preferred as it allows me to use it for multiple meta values:
if ( $query->have_posts() ) { ?>
<div class="schedule-container">
<?php while ( $query->have_posts() ) : $query->the_post();
$programmeImage = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') );
$programmeMeta = get_post_meta($post->ID,'_meta_content',TRUE);
?>
<div id="programme-<?php the_ID(); ?>" <?php post_class(); ?> style="background-image: url( <?php echo $programmeImage ?> )">
<div class="schedule-titlebar">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php echo $programmeMeta['broadcast-date'] ?></p>
</div>
</div>
<?php endwhile;
wp_reset_postdata(); ?>
</ul>
}
But that didn't work so I tried this instead:
if ( $query->have_posts() ) { ?>
<div class="schedule-container">
<?php while ( $query->have_posts() ) : $query->the_post();
$programmeImage = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail') );
$programmeBroadcastDate = get_post_meta($post->ID,'broadcast-date',TRUE);
?>
<div id="programme-<?php the_ID(); ?>" <?php post_class(); ?> style="background-image: url( <?php echo $programmeImage ?> )">
<div class="schedule-titlebar">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php echo $programmeBroadcastDate ?></p>
</div>
</div>
<?php endwhile;
wp_reset_postdata(); ?>
</ul>
}
and that doesn't work either!
Any ideas? Thanks