Think I’ve figured this out. For anyone who has similar issues in the future, I believe that the solution has to do with whether or not you are using the:
get_post_meta($post->ID, '$key', true);
within The Loop. For anyone experiencing similar problems, I have found that changing $post->ID to get_the_ID() if you are outside the loop should do the trick.
Hey guys,
I’m actually having this same problem. The only difference (and reason why the solution here doesn’t work) is that my get_post_meta() is located inside a loop. Both get_the_ID() and $post->ID do not work in either case. Everything was working prior to upgrading to 3.4. The template that contains this code is very custom to build out a list of available classes and course topics. Here’s a sample, hopefully it’s enough to try and help me:
if (have_posts()) : while (have_posts()) : the_post();
$ClassroomDates = get_post_meta($post->ID, "classroom_date", false);
foreach($ClassroomDates as $individual_classroom_date) {
$first_date = substr($individual_classroom_date, 0, 10);
echo "<tr>";
echo "<td>CLASSROOM</td><td>"; ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php
echo "</td>";
echo '<td>'.$first_date.'</td>';
echo '<td>';
echo get_post_meta($post->ID, "duration", true);
echo '</td>';
echo '<td class="price-cell">'; ?>
<?php echo '$'; echo get_post_meta($post->ID, 'price', true); ?>
<?php
echo '</td><td>';
echo '<form class="foxycart" action="https://envision.foxycart.com/cart" method="post" accept-charset="utf-8">
<input type="hidden" name="name" value="'; ?>
<?php the_title(); echo " - $individual_classroom_date - Classroom"; ?>
<?php echo '" />
<input type="hidden" name="price" value="'; ?>
<?php echo get_post_meta($post->ID, 'price', true); ?>
<?php echo '" />
<input type="submit" value="Register" class="submit" />
</form>';
echo "</td></tr>";
}
If you can help me shed any light on this, that would be great. It’s for a client that needs it working, thank you!