trouble with array returns from get_post_meta
-
Hi everyone.
I’m trying to load up the category in the loop using post meta data.
As I understand it (I’m a hack mind you) the get_post_meta function below is set to return a single value, not an array (the boolean “true”).
<?php $cat = get_post_meta($post->ID, $catslug, true); ?>
<?php query_posts('category_name=' . $cat ); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile;?>
But when I print the variables I get “array” as the result for both, and no loop output. (this is how I printed the variables, right after the loop).
<p>catslug = <?php echo get_post_meta($post->ID, $catslug, true ); ?></p>
<p>cat = <?php echo $cat; ?></p>All this is happening on a page, after the normal page loop. In this case there are two meta datas:
catslug: “mtgravatt”
menu: “Mount Gravatt”Funny thing was, I swear this was working. Then I went and changed the category slugs and updated the custom fields, and I started getting the array results.
Cache cleared, still the same.
Ali
- The topic ‘trouble with array returns from get_post_meta’ is closed to new replies.