phpwordpresstemplateswordpress-thesis-theme

Why isn't get_post_meta working?


Simple Wordpress problem - get_post_meta is not retrieving custom field values. Here's the code that is pulling from the custom fields:

<img src="<?php echo FCG_PLUGIN_URL; ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, 'slider_image', true); ?>&h=250&w=400&zc=1" alt="<?php echo $post_title; ?>" />

In production, this is the HTML I get:

<img alt="Post Title" src="http://***.com/wp-content/plugins/jquery-slider-for-featured-content/scripts/timthumb.php?src=/&amp;h=50&amp;w=80&amp;zc=1">

You can see the src= point in the string is empty - as if there is nothing posting from it. I have isolated and echo'd just the get_post_meta and it's a whitespace. I am 100% sure it's named correctly within the post - is there something glaring I'm missing here?


Solution

  • Search for the term "slider_image" in the wp_posts and wp_postmeta tables using phpmyadmin. Then view the row that has it to see if there's anything inside.

    Also try changing the name of the custom value as a test and see if that works. I use this exact code to do something similar to you and it works:

    <p><a href="<?php echo get_post_meta($post->ID, 'resume', true) ?>"><img src="<? bloginfo('template_url'); ?>/img/downloadresume.png"></a></p>