• I found this useful code (https://www.wprecipes.com/wordpress-how-to-get-custom-fields-outside-the-loop/) for display custom fields post outside loop. It works fine, but I don’t know how to separate every custom fields in list. I tried this code but it don’t work

    <div class="data">
    <h3>Features</h3>
    <ul>List
    <?php
    global $wp_query;
    $postid = $wp_query->post->ID;
    <li>echo get_post_meta($postid, 'price', true);</li>
    <li>echo get_post_meta($postid, 'place', true);</li>
    wp_reset_query();
    ?></ul>
    </div>
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ddorr

    (@ddorr)

    Sorry, but I realized that my question fit better in Fixing WordPress

    question fits better into: how to understand using html tags within php code….

    one possible way:

    <div class="data">
    <h3>Features</h3>
    <ul>List
    <?php
    global $wp_query;
    $postid = $wp_query->post->ID; ?>
    <li><?php echo get_post_meta($postid, 'price', true); ?></li>
    <li><?php echo get_post_meta($postid, 'place', true); ?></li>
    <?php wp_reset_query();
    ?></ul>
    </div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to put custom fields in a list outside loop’ is closed to new replies.