Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:49:35+00:00 2026-06-14T20:49:35+00:00

[edit] TLDR: The answer: don’t use echo , but print_r I have tried the

  • 0

[edit]
TLDR: The answer: don’t use echo, but print_r

I have tried the following to get the meta value as a string, instead of an Array. The third value is set to true, so this should result as a string.

<?php

    // The data
    $projects = $wpdb->get_results( "SELECT * FROM $wpdb->posts" ); 


    // Loop them
    foreach ( $projects as $project ) 
    {
        // Get the meta
        $metas = get_post_meta( $project->ID,'bc_invited', true );

        // This is rendering
        echo '<h2>' . $project->post_title . '</h2>';

        foreach($metas as $meta){
            // This is not rendering
            echo $meta . '<br/>';
        }

    }
?>

Why am I not seeing what I expected?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:49:37+00:00Added an answer on June 14, 2026 at 8:49 pm

    the get_post_meta function receve the the third parameter as (boolean) (optional) If set to true then the function will return a single result, as a string.

    If false, or not set, then the function returns an array of the custom fields. This may not be intuitive in the context of serialized arrays. If you fetch a serialized array with this method you want $single to be true to actually get an unserialized array back. If you pass in false, or leave it out, you will have an array of one, and the value at index 0 will be the serialized string.
    Default: false

     <?php $meta_values = get_post_meta($post_id, $key, $single); ?>
    

    now your problem is you returned the meta as array and used the echo which caused the problem you have to use print_r instead to see the result

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: See my answer below--> I am wanting to have a view that when
EDIT: I'd like to get a definitive answer on whether or not it's possible
EDIT Leaving this for posterity, but nearly a year later, to get down voted,
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
Edit (updated question) I have a simple C program: // it is not important
Edit : Note that, as Daniel and latkin noted in an answer and a
EDIT: More detail here. Basically if you 1. open a tab1 to url1 (GET
Edit: From another question I provided an answer that has links to a lot
Edit: I think I figured out the solution, but I'm still interested to know
EDIT: I rephrased the question because I have not explained well. Let's see if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.