Greetings,
I can't get the value of a custom field assigned to a string variable inside a plugin for the life of me.
Here is what I've done so far..
I added this function to functions.php in my theme..
function get_custom_field_value($szKey, $bPrint = false) {
global $post;
$szValue = get_post_meta($post->ID, $szKey, true);
if ( $bPrint == false ) return $szValue; else echo $szValue;
}
Inside the plugin, I added this code..
if ( function_exists('get_custom_field_value') ){
$custom_field = get_custom_field_value('custom_field_name', false);
}
Where custom_field_name is the name of my custom field.
So, I add a new post, select the custom field and give it a value, add it. Publish the post.
The value never gets assigned to $custom_field.
I've searched the web and all posts seem to lead back to using this method. I just can't get it to work
Where am I going wrong here?
Thanks!!