PHP/WordPress: Custom Field Value in Loop returns Array instead of Single Result

For the search results page in WordPress Im making a custom template. And in that custom template I want to display custom meta field values.

However, when I do this:

Read More
<?php if ( have_posts() ) : ?>

    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>

        <?php
        $pName = get_post_meta($post->ID, $productName, true);
        echo $pName;
 );
    ?>
    <?php endwhile; ?>

    <?php else : ?>
        <?php get_template_part( 'content', 'none' ); ?>

<?php endif;

The result I get is not the value of the custom field but:

Array

When I var_dump the $pName it shows all the right custom field content.

Question: Why am I getting an array as the result (when Ive told it its a single result with ‘true’) and how do I fix it so it displays the proper content?

Thanks!

Related posts

Leave a Reply