Support » Fixing WordPress » Cant Read Custom Fields

  • Resolved mondomx


    I have a custom field of hasImage -> yes on Pages (and posts). It shows up in the database as being set on multiple entries. But when i use the_meta(), c2c plugin, and post_custom(), and nothing displays this information. I even checked the CSS to make sure it was set with visible attributes. Any ideas why this meta data wont show?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Update
    I was printing it outside a div, so it was appearing behind another div that I set the background color on. Now when I use the_meta() I get hasImage: yes _wp_template: default as it shows in the DB. However, I cant READ this value to a var so I can test for it…
    $himage = get_post_custom_values('hasImage');
    echo "Image-> " . $himage;

    Gives me “Image -> ”

    get_post_custom_values() returns an array, so it’ll take a bit more to get a single value out of it:

    foreach(get_post_custom_values('hasImage') as $himage)
    echo "Image-> " . $himage;

    Doesnt work either… never steps through the loop. I tried printing $himage[0] outside the loop as well, and get nothing, and tried it without the loop and using [0], nothing.

    $query = "SELECT * FROM boxer_postmeta WHERE post_id = '2' AND meta_key = 'hasImage' LIMIT 1";
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $r = $row['meta_value'];

    This prints out the correct value, but the get custom functions pass back nothing. Im guessing Im the only one having this trouble, I will have to test on a new install… but until then, Im going to settle with this work around.

    Where are you running this in your template(s)? Is it inside or outside of The Loop? If in The Loop, is it a custom loop?



    I am having the same problems with using custom fields in WPv2.0.

    Trying to use Bunny’s Techorati tags plugin… debugging it I get nothing returned from this call:

    $tags = get_post_custom_values($meta_field);

    I’ve verified that the $meta_field is ‘tags’ and that the post I’m trying to access them on actually does have values for the ‘tags’ custom field, and also that the call to the plugin is happening in “the loop”.

    Can anyone help me figure out what’s going on? I’d greatly appreciate it! Thanks.



    I couldn’t figure out why my Bunny’s Technorati tags plugin was not working either, even though I had upgraded it to the WP2.0 compatible version.

    But after reading this thread, I started checking each and every one of my plugins.

    Turns out, in my case, I had an old version of the Adhesive plugin that was interfering with custom fields. I disabled the Adhesive plugin and my custom fields and Bunny’s Technorati Tags are working again. There’s an WP2 compatible version of Adhesive available, but I don’t use sticky posts often, so might upgrade later.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Cant Read Custom Fields’ is closed to new replies.