0

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?

1
  • 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. Commented Nov 11, 2012 at 21:52

1 Answer 1

-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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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