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 7950665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:20:36+00:00 2026-06-04T02:20:36+00:00

I have a table (wp_postmeta), which contains four columns (meta_id, post_id, meta_key, meta_value). meta_key

  • 0

I have a table (wp_postmeta), which contains four columns (meta_id, post_id, meta_key, meta_value). meta_key contains a field called neighborhood_value and the values for neighborhood_value are stored under the meta_value column. How do I retrieve the contents of neighborhood_value from my table and use them as a variable? Any support is appreciated

  • 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-04T02:20:38+00:00Added an answer on June 4, 2026 at 2:20 am

    Ok, as everything is meta, thecode will also be “meta” 🙂

    UPDATE – now when I know what you use to connect to DB I can change my answer to be more specific.

    global $wpdb;
    
    $sql = "SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=XXX";
    
    $retMeta = array();
    $results = $wpdb->get_results($sql);
    
    foreach ($results as $resultRow)
    {
        if (!isset($retMeta[$resultRow['meta_key']]))
        {
            $retMeta[$resultRow['meta_key']] = array();
        }
        $retMeta[$resultRow['meta_key']][] = $resultRow['meta_value'];
    }
    

    The resulting $retMeta will be two dimensional array, and then you will be able to access your neighbourhood value by using $retMeta[‘neighbourhood_value’][0] (of course first you have to check if this is set – isset($retMeta['neighbourhood_value'])).

    UPDATE2

    For script imporing data, it’ll look like that:

    $sql = "SELECT meta_key, meta_value FROM wp_postmeta WHERE post_id=XXX";
    
    $retMeta = array();
    $result = mysql_query($sql);
    
    while ($resultRow= mysql_fetch_assoc($result))
    {
        if (!isset($retMeta[$resultRow['meta_key']]))
        {
            $retMeta[$resultRow['meta_key']] = array();
        }
        $retMeta[$resultRow['meta_key']][] = $resultRow['meta_value'];
    }
    mysql_free_result($result);
    

    But you should use WP_Query anyway, to maintain portability (the wp_postmeta doesn’t have to be named that way, it can be wp2_postmeta etc).

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

Sidebar

Related Questions

I have a table wp_postmeta with columns called meta_key and meta_value . I have
I have a table called wp-posts with a field post-content. This field contains the
I have a MYSQL database table called 'wp_quotes' with a field that contains a
I have the following table: ratings: ID | post_id | rating_type The rating_type field
I have table in which I am inserting rows for employee but next time
I have table with two columns (varchar from, varchar to). This table represents connections
I have a custom table called wp_purchases that is added to by a Paypal
I have a Wordpress site which has post ratings stored in the wp_ratings table,
I have this query: $query = SELECT *FROM wp_postmeta WHERE meta_key = '_isEvent' AND
I have to parse wordpress post_meta table , particularly _wp_attachment_metadata field For example: Its

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.