Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Inside of my WordPress theme directory I have a standalone PHP file called image, this currently looks like this....

<?php
  define('WP_USE_THEMES', false);
  require('/home/mysite/public_html/wp-blog-header.php');
?>

<?php
  global $post;
  $post_id = 288;
  $header_image = get_post_custom_values('caption', $post_id);
    echo get_post_meta($post_id, 'caption', true);
?>

When I visit this site I want it to return the custom field value for 'caption' but I am getting nothing. I realise this page is outside of the loop but I thought I have included the wp-blog-header.php that it needed. Can anyone help?

share|improve this question
2  
Can you explain what you're trying to accomplish? You've provided us with an implementation, but no context regarding why you're trying to use this particular implementation. If we know what you're ultimately trying to accomplish, we can probably provide a much better answer. –  Chip Bennett Nov 11 '12 at 21:52

1 Answer 1

<?php
  define('WP_USE_THEMES', false);
  require('wp-blog-header.php');
?>

<?php
    $post_id = 288;
    echo get_post_meta($post_id, 'caption', true);
?>

That part is enough - are you sure that this is the name of your custom field and the path to wp-blog-header is resolved and valid?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.