Support » Plugins » Hacks » Custom Fields from data base outside the loop

  • Hello.
    I want to display a Custom Fields from data base outside the loop, for exemple in this plugin (Igit related posts wordpress plugin). I want to disply the custom field after the image generated by this plugin. Can You help me ?

    With this code <?php echo get_post_meta($GLOBALS['current_id'], "custom-field-name", true); ?> in footer.php or sidebar.php everything seems ok, but the custom field not appear if i put this code on the plugin files.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Just learned this… You can display custom fields outside of the loop with the following code.

    global $wp_query;
    $postid = $wp_query->post->ID;
    echo get_post_meta($postid, 'Your-Custom-Field', true);


    Hope that helps and good-luck!

    Not work. I habe a blank page with this code. Is not ok !

    A blank page is a PHP error. Dig into your server’s error logs to find out why the code didn’t work.

    [Tue Apr 05 16:39:15 2011] [error] [client] PHP Parse error: syntax error, unexpected T_STRING in /var/www/vhosts/ on line 393, referer:

    Turn of the igit-related-posts-with-thumb-images-after-posts plugin and things should work again. Also, you may need to go in via FTP and delete the plugin (back it up first if needed).

    Hey, I want to put this code to show the price (custom field) after every image generated by this pugin.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom Fields from data base outside the loop’ is closed to new replies.