I am trying to use get_post_meta to return a value from the post meta, it was working completely fine then suddenly stopped working. I've tried and checked everything and i cannot seem to get it working again - the code i'm using is as below - no matter what i do, i cannot return the meta value for the meta field any more.
The code is added to functions.php.
function latest() {
$args = array( 'posts_per_page' => 1);
$last_5_posts_query = new WP_Query( $args );
while($last_5_posts_query->have_posts()) :
$last_5_posts_query->the_post();
$link = get_permalink();
$title = get_the_title();
$title1 = get_post_meta(get_the_ID(), 'Title 1', true);
$title2 = get_post_meta(get_the_ID(), 'Title 2', true);
$more = 'Read more...';
$content .= '<div class="top_titles">';
$content .= '<h3><a href="#top_titles">' .$title1. '</a></h3>';
$content .= '<h3><a href="#top_titles">' .$title2. '</a></h3>';
$content .= '</div>';
endwhile;
return $content;
}
Any ideas? The meat names "Title 1" and "Title 2" still exist. Completely out of ideas.